Jesse - 2013-10-04

I have written a for look in ksh that calls expect to login to multiple servers. I execute shell script to loop through Server list. Within loop I call out expect script to log into each server send uname -ns command to get hostname and OS. I have mix of Solaris, Linux, HP servers and would like to get output of each servers. Now how do I get output sent to primary server that I run script from. Here is what I have.

Shell script


for var in cat hostlist
expect.uname $var;

Here is my expect.uname script


set timeout 20
set server_name [lindex $argv 0]
spawn ssh "$server_name"
set output [open "outputfile.txt" "a+"]
sleep 2
send "uname -ns\n"
expect "*$"
set outcome $expect_out(buffer)
send "\r"
puts $output $outcome
send "exit\r";

I loop through all the servers correctly.
how do I retrieve the outputfile.txt and did I do this correctly?

I'm very new at expect