expect - problem split argv 0, then send each item as command



When I execute the following script via: ./go.exp
"date;hostname;uname"
I only get output from the puts line, instead of actually sending the
commands to a shell. What am I missing? Is there a problem putting an
expect block inside a foreach loop?

-Inet


#!/usr/bin/expect

foreach element [ split [lindex $argv 0] ";" ] {
puts "sending: $element\n"
expect {
-re ".*$" { send -- "$element\r" }
}
}

-------
-------

../go.exp "date;hostname;uname"
sending: date

sending: hostname

sending: uname


.



Relevant Pages