expect 自动交互命令

推荐一个比较详细的博客 https://www.cnblogs.com/autopenguin/p/5918717.html

功能:

自动交互命令

格式:

yum -y install expect

#!/usr/bin/expect

执行 

expect expect.sh

参数:

-P //端口

命令:

spawn 执行shell命令的

expect  匹配到

send 返回值

实例:

1.免密交互

#!/usr/bin/expect
set timeout 10 //如果10秒内没有任务执行就退出
spawn ssh root@10.0.0.43
expect "*password*"
send "123456\r"
interact
       
posted @ 2020-01-15 17:52  Databasess  阅读(246)  评论(0编辑  收藏  举报