Using an expect Script to send the output of a command and store in a file
问题 Hi I am trying to store the output of a command run through a spawn ssh remote window into my local host, I am new to expect and am not able to figure out where I am wrong. My Code: #!/bin/bash while read line do /usr/bin/expect <<EOD spawn ssh mininet@$line expect "assword:" send -- "mininet\r" set output [open "outputfile.txt" "a+"] expect "mininet@mininet-vm:*" send -- "ls\r" set outcome $expect_out(buffer) send "\r" puts $output "$outcome" close $output expect "mininet@mininet-vm:*" send