set commands {"show phone xxx 11""show phone yyy 22""show phone zzz 33"}spawn ssh -o StrictHostKeyChecking=no $UserId@$hostsleep 15#wait for password promptexpect "*assword:"#send password send -- "$Passwd\r"sleep 5foreach cmd $commands { set logfile [join [lrange [split $cmd] 2 end] _] log_file -a $logfile send -- "$cmd\r" expect -re "admin:" exp_sleep 8 log_file}
was not able redirect command's output to respective log file.
xxx_11 log file contains 'spawn ssh -o StrictHostKeyChecking=no $UserId@$host' output.yyy_22 log file contains 'show phone xxx 11' command output.zzz_33 log file contains 'show phone yyy 22' command output.
How to write log files in the following way:
XXX_11 log file contains 'show phone xxx 11' command outputyyy_22 log file contains 'show phone yyy 22' command outputzzz_33 log file contains 'show phone zzz 33' command output
Thanks in adavnce for help.