【发布时间】:2012-08-31 18:02:36
【问题描述】:
我正在使用 expect 来生成一个 sftp 会话,如下所示:
(为了清楚起见,剪掉了很多代码,是的,我理解其中的风险......)
#!/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
这很好用。
我的具体问题是如何在文件中捕获 send "ls -l\r" 命令的结果。
【问题讨论】: