首页 > 其他 > 详细

expect 使用

时间:2016-11-11 20:09:50      阅读:185      评论:0      收藏:0      [点我收藏+]

参考:http://www.cnblogs.com/iloveyoucc/archive/2012/05/11/2496433.html

 

 

自己的小例子:

  1. ssh 到堡垒机
  2. 选择跳转服务器
  3. ssh 到目标服务器
  4. cd 到目录

login_ssh.exp

 1 #!/usr/bin/expect
 2 set timeout 30
 3 spawn ssh  xxx@xxx
 4 expect "Password:"
 5 send "xxx\r"
 6 expect "Select server:"
 7 send "x\r"
 8 expect -re ".*xxx.*"
 9 spawn ssh xxx@xxx
10 expect -re ".*password:"
11 send "xxx\r"
12 expect -re ".*xxx.*"
13 send "cd /xxx\r"
14 interact

 

expect 使用

原文:http://www.cnblogs.com/jellyabd/p/6055030.html

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