expect 实例

实例一:拷贝远程ssh_config文件到/etc/ssh下

#!/bin/bash
while read ip
do
ip=$ip
/usr/bin/expect <<EOF
set timeout 1
spawn  ssh -t username@$ip sudo  mv /home/deployer/ssh_config /etc/ssh/ssh_config
expect "(yes/no)?"  { send "yes\r";exp_continue }
expect   "password:"  { send "mypasswd\r";exp_continue }
expect  "deployer:"  { send "mypasswd\r";exp_continue }
expect eof
EOF
done < ip.txt

  

 

上一篇:ubuntu使用ssh远程登陆操作ubuntu


下一篇:Java多线程之通俗易懂讲解CAS