I am using expect to spawn a sftp session as follows:
(lots of code snipped for clarity, and yes I understand the risks...)
#!/opt/csw/bin/expect -f
<snip>
spawn sftp $user@$host
set rez [connect $passw]
if { $rez == 0 } {
send "cd $location\r"
set timeout -1
send "ls -l\r"
send "quit\r"
expect eof
exit 0
}
puts "\nError connecting to server: $host, user: $user and password: $passw!\n"
exit 1
This works just fine.
My specific question is how to I capture the results of the send "ls -l\r" command in a file.