Can the expect utility handle a case where the process it spawns also spawns a sub process?

Posted by davidparks21 on Super User See other posts from Super User or by davidparks21
Published on 2011-06-27T06:37:39Z Indexed on 2011/06/27 8:25 UTC
Read the original article Hit count: 258

Filed under:
|
|
|

I'm trying to use expect to handle rsync over an ssh shell, but it gets stuck.

If I run my rsync command it works (simplified here): It prompts me for my password and copies files to the server:

rsync -e ssh -<other_params>

If I then enclose that in expect:

expect -d -c "spawn rsync -e ssh -<other_params>" -c "expect password:" -c "send mypass\r"

It does not execute properly, the program exists and no files are copied. Even the debug mode isn't giving many clues.

My best guess is that rsync is spawning the ssh process, and the ssh process is what needs to be interacted with, but send is picking up the rsync process id and sending the input there.

Any thoughts?

© Super User or respective owner

Related posts about linux

Related posts about ssh