#!/usr/bin/expect -f
set arg0 [ lindex $argv 0 ]
set arg1 [ lindex $argv 1 ]
set remoteip "172.31.13.101"
send_user "good/n"
spawn /usr/bin/scp emptydoc $remoteip:/home/xiawenbing/
expect "yes/no)?" {send "yes/r"} "password:" {send "realpassword/r"}
expect eof
exit
倒数第三行的 expect 行, 不能断成多行, 也不能分拆成多个平行的expect语句
本文介绍了一个使用Expect脚本实现SSH远程文件传输的例子。该脚本通过自动化处理交互过程来简化从本地向远程服务器传输文件的操作。它包含了对用户确认、密码输入等步骤的自动响应。

被折叠的 条评论
为什么被折叠?



