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.
for var in cat hostlist
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+"]
send "uname -ns\n"
set outcome $expect_out(buffer)
puts $output $outcome
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
Log in to post a comment.