expect 远程执行命令-01

+++++++++++++++++++++++++++++++++++++++++++++

标题:expect 远程执行命令-01

时间:2020年3月3日

+++++++++++++++++++++++++++++++++++++++++++++

 

# yum -y install expect    安装expect的应用程序

 

#/usr/bin/env expect

set  ip  192.168.100.100

set  user  root

set  password  centos

set  timeout  5

spawn ssh ${user}@${ip}

expect {

  "yes/no" { send "yes\r" ; exp_continue }

  "password" { send "${password}\r" }

}

interact    #将停止在登录的服务器,等待操作

 

posted @ 2020-03-03 19:32  叼着辣条的猫  阅读(204)  评论(0编辑  收藏  举报