expect 自动应答 TCL 语言
需求 1: 远程登录到 A 主机, 什么事情也不做
- #! /usr/bin/env expect
- # 开启一个程序
- spawn SSH [email protected]192.144.213.113
- # 捕获相关内容
- expect {
- "(yes/no)?" { send "yes\r";exp_continue }
- "password:" { send "Lzw18519331036\r" }
- }
- interact // 交互
需求 2: 远程登录 A 主机, 做一些事情
- #! /usr/bin/env expect
- set ip 192.144.213.113
- set pass Lzw18519331036
- spawn SSH [email protected]$ip
- expect {
- }
来源: http://www.bubuko.com/infodetail-3259950.html