开发者

how to wrap a script spawning multiple processes with Expect?

I'm running "hg fpull" that pulls via ssh. I'd like to feed it with the passwor开发者_StackOverflow社区d only ones. Yes, I'm aware about ssh-keygen, but Expect would be more preferable for me.

So, here is the script:

#!/usr/bin/expect

stty -echo
send_user "Password: "
expect_user -re "(.*)\n"
set password $expect_out(1,string)
send_user "\n"
stty echo

spawn hg fpull -u --snapfile <snapfile>
expect {
    "Password:" { send "$password\r"; exp_continue; }
}
interact

The problem is that "hg fpull" spawns a new process to pull from a new repository. A new process gets Expect out of the cycle...

So, how to deal with this? Is that possible at all with Expect? Thanks in advance!


If I understand you correctly, what is required is that you get the #spawn_id for your spawned process. You can then match per process (expect -i ) and close per process.

There is a nice example here: http://wiki.tcl.tk/16158

I am not sure what you mean with the password once bit. Does this apply per "hg pull" or is it overall.

In the latter case you might want to do that in an overall expect script that then spawns childs with whom you communicate the password that is stored during runtime.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜