Expect is a great tool, and so is the TCL language (pronounced tickle)... (go ahead Matt and Adam, I can hear you both snickering :) ) Rick, here is another way (little shorter) to accomplish what you've outlined above:
proc doWork {host} { puts stdout "host is $host" } set fp [open <path to>/hostsFile.txt r] while {[gets $fp line] > -1} { set host [string trim $line] if {![string match "#*" $host] && [string length $host]} { doWork $host } } close $fp
On another note, if this is something you might run quite a bit, and you don't really need the interactive nature of expect, you could update the ssh keys for all hosts and simply call
puts stdout "response from $host:
[exec ssh $host <path to>/remoteScript.tclsh]"
within your "doWork" proc... (multi-line strings are not an issue.) There is a great HOWTO listed here regarding ssh-keygen : http://www.arches.uga.edu/~pkeck/ssh/
If you want to find out if you have expect loaded (it's an extension to TCL so you might not have it with your installation) you can issue the following command within a tclsh shell
Expect is a great tool, and so is the TCL language (pronounced tickle)... (go ahead Matt and Adam, I can hear you both snickering :) ) Rick, here is another way (little shorter) to accomplish what you've outlined above:
On another note, if this is something you might run quite a bit, and you don't really need the interactive nature of expect, you could update the ssh keys for all hosts and simply call
within your "doWork" proc... (multi-line strings are not an issue.) There is a great HOWTO listed here regarding ssh-keygen : http://www.arches.uga.edu/~pkeck/ssh/
If you want to find out if you have expect loaded (it's an extension to TCL so you might not have it with your installation) you can issue the following command within a tclsh shell
If nothing comes back, you have to go get the extension (here: http://expect.nist.gov/