expect使用

#!/bin/bash
/usr/bin/expect  << EOF
spawn ssh root@60.32.0.19
expect {
"yes/no*"  { send "yes\r"; exp_continue }
"*assword:" { send "m2a1s2u30000049\r" }
}
expect "root@fort2:~#"
send "df -lh\r"
expect "root@fort2:~#"
send "exit\r"
EOF

 

posted @ 2017-07-19 16:13  正在努力的BOY  阅读(134)  评论(0编辑  收藏  举报