【发布时间】:2014-09-20 07:11:18
【问题描述】:
我真的很难过! 我不想使用 RSA AUTH,所以请弃权。
#!/bin/bash
echo "Enter the server password"
read password
cd /home/mike/
# this is included the code below ->
/usr/bin/expect << EOD
set timeout -1
spawn scp file.txt server.com:/home
expect {
timeout { send_user "TIME OUT\n"; exit 1 }
"*assword: "
}
send "$password\r"
expect {
"s password: " { send_user "\nIncorrect Password. Login Failed.\n"; exit 1 }
"100%"
}
sleep 1
send "exit\r"
expect eof
这有效,file.txt 被传输到服务器,但我收到此警告消息 ->
" line 44: warning: here-document at line 22 delimited by end-of-file (wanted `EOD')"
当我在“期望 eof”之后添加 EOD 时,它给了我这个错误 ->
send: spawn id exp4 not open
while executing
"send "exit\r"
任何帮助将不胜感激。 我再说一遍我不能使用 pubkey auth 所以请不要建议。
【问题讨论】:
-
您为什么要向
scp会话发送“退出”?当你直接使用scp时,你会这样做吗?