yum install expect*
自动登录脚本如下:
#! /usr/bin/expect -f
set timeout 3
spawn ssh -p 22 root@111.111.111.111
expect {
"*yes/no" {send "yes\r";exp_continue}
}
expect "*password:"
send "123456789@#\r"
expect "root@*" {send "ls /opt\r"}
expect "root@*" {send "exit\r"}
interact
本文转自 guowang327 51CTO博客,原文链接:http://blog.51cto.com/guowang327/1795555,如需转载请自行联系原作者