码迷,mamicode.com
首页 > 其他好文 > 详细

expect

时间:2018-08-11 22:07:19      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:nec   pass   fuse   code   refused   word   miss   use   cti   

#!/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

标签:nec   pass   fuse   code   refused   word   miss   use   cti   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!