Re: Quick question about expect

Babylon wrote:

The reason I want this to work, is because the plan is to use that expect script, and wrap it with a shell script I have to connect to about 20 servers at the same time.... and I need them to be accessible via screens... hope this makes sense..

Again, I really appreciate the help!

you don't want to use screen for that.

expect can give that functionality on its own.

read "man expect" read all, than look for "interact"
( expect is rather feature rich, and you should get an idea
what it can do )
read "the book" i.e. Exploring Expect by Don Libes
there is a chapter that talks about emulating screen (afair)

# do a spawn for every session you want.

set jobs {
root bongo blabla
root bingo blurp
nobody darkhole ""
set idx 0
foreach {user host passwd} $jobs {
set :A(($idx,user $user
set :A($idx,host) $host

spawn ssh ${user}@$host
set ::A($idx,spid) $spawn_id
# do the login stuff for each host
# done
lappend ::A(connections) $host
incr idx

# now talk to your sessions by
# expecting:
set currhost bingo
set curr [ lsearch $::A(connections) $currhost ]
# set curr 1

expect -i $::A($curr,spid) ....

exp_send -i $::A($curr,spid) ...

# or use interact with apropriate args.

do i get piano-lessons for free now ?