脚本如下: #!/usr/local/bin/expect
set timeout -1
#主机 IP
set hostIp [lindex $argv 0]
#IP 的端口
set ipPort [lindex $argv 1]
#用户名
set userName [lindex $argv 2]
#密码
set userPassword [lindex $argv 3]
#远程主机目录
set remoteDir [lindex $argv 4]
#本地主机目录
set localDir [lindex $argv 5]
#scp 拷贝指令 spawn scp -P $ipPort -r $userName@$hostIp:$remoteDir/* $localDir
expect { "yes/no" { send "yes\r"; exp_continue} "password:" { send $userPassword; send "\r"} }
expect { "denied" { send "\r";exit -1;} }
expect eof
开始的时候,没有 expect { "denied" { send "\r";exit -1;} }这段代码,所以没有提示信息。一旦有了这段代码一直提示 send: spawn id exp4 not open。这个问题怎么处理啊?怎么样避免这个提示出现啊?