執行完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 "\]# "