歡迎您光臨本站 註冊首頁

expect調用不了遠程主機上的shell腳本

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

執行完expect腳本之後,遠程主機上的test.sh沒有被執行?
大牛們,這個腳本錯在哪裡了。。。。
expext腳本如下:
#!/usr/bin/expect -f
set ipaddress
set passwd   
set timeout 30
spawn ssh root@$ipaddress
expect {
        "yes/no" { send "yes\r";exp_continue }
        "password:" { send "$passwd\r" }
}
send "cd /root \r"
send "/bin/bash test.sh \r"
send "exit\r"
expect eof
exit

在每個send後面加上試試
例如:
send "cd /root \r"
expect -re "\]# "




[火星人 ] expect調用不了遠程主機上的shell腳本已經有451次圍觀

http://coctec.com/docs/service/show-post-449.html