参考:http://www.cnblogs.com/iloveyoucc/archive/2012/05/11/2496433.html
自己的小例子:
- ssh 到堡垒机
- 选择跳转服务器
- ssh 到目标服务器
- cd 到目录
login_ssh.exp
1 #!/usr/bin/expect 2 set timeout 30 3 spawn ssh [email protected] 4 expect "Password:" 5 send "xxx\r" 6 expect "Select server:" 7 send "x\r" 8 expect -re ".*xxx.*" 9 spawn ssh [email protected] 10 expect -re ".*password:" 11 send "xxx\r" 12 expect -re ".*xxx.*" 13 send "cd /xxx\r" 14 interact
时间: 2024-10-27 04:39:09