#!/usr/bin/expect -f
spawn ssh [email protected].*
expect "*password*"
send "*qwe123\r"
expect "*#"
send "cd /home/data/test\r"
expect "*#"
send "rm ./*\r"
expect {
"*是否*" {send "y\r"}
"*沒有*" {send "\r"}
}
interact
mac系統將後綴名改爲.command成爲雙擊可執行文件