expect 自动交互命令

功能:

自动交互命令

格式:

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 [email protected]
expect "*password*"
send "123456\r"
interact
     

  

猜你喜欢

转载自www.cnblogs.com/gaiting/p/12175228.html