#!/usr/bin/expect
# 开启一个程序
spawn ssh root@10.1.1.1
# 捕获相关内容
expect {
"(yes/no)?" { send "yes\r";exp_continue }
"password:" { send "123456\r" }
}
interact //交互
首先安装expect
# yum install expect -y
脚本执行方式:
# ./expect1.sh
# /shell04/expect1.sh
# expect -f expect1.sh
网友评论