首页 > 其他 > 详细

expect

时间:2018-08-11 21:21:52      阅读:155      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
passwd=‘nihao23d23d
/usr/bin/expect << _EOF
spawn ssh -p22 flli@10.189.103.12
expect {
         "Are you sure you want to continue connecting (yes/no)?" {
              send "yes\r"
       }
         "*password:" {
             send "${passwd}\r"
       }
         "Permission denied, please try again." { 
             exit 
       }
         "Connection refused" {
             exit
       }
        timeout {
             exit
       }
        eof {
            exit
      }
}
expect "*$"
send "hostname\r"
expect "*$"
send "exit\r"
expect eof
_EOF

 

expect

原文:https://www.cnblogs.com/ilifeilong/p/9460990.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!