expect with forking multiple foreground processes
- From: nazrat <newtan@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 17:46:13 -0800 (PST)
Hi all,
I have read up the Expect manpage and a other examples for fork. The
manpage warns that always fork first before spawning processes, but I
can't quite figure out how to come up with a solution for my problem
as described.
I'd like to simultaneously ssh to several remote machines to run a
command via ssh, wait for the output from each of the machine to come
back to my terminal and then exit. I would like to enter the password
only once and it should be cached and fed to the ssh sessions. How can
i get around this with expect/fork? Thanks much.
I am totally a newbie to tcl/expect (just read the manpage) so bare
with me the following miserable attempt:
#!/usr/bin/expect --
send_user "Please enter password: "
expect_user -re "(.*)\n"
for {set i 1} {i < 10} {incr i} {
if {[fork] == 0} {
set host "host$i"
eval spawn -noecho ssh $host 'uname -a'
expect "password:"
send "$expect_out(1,string)\r"
exit
}
}
My questions are:
1 - how can i wait for the forked subprocesses in the parent (control)
process?
2 - if the entered password is incorrect, how can a subprocess inform
the control process so it can re-prompt the user to enter again?
Thanks much.
.
- Prev by Date: Re: Why doesn't foreach return a value
- Next by Date: Re: Why doesn't foreach return a value
- Previous by thread: Cisco TCL script to parse ANI/DNIS fields
- Next by thread: Re: Errors in building tcl 8.4.2 from source in Windows 2000
- Index(es):
Relevant Pages
|