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
记录学习和生活的酸甜苦辣.....哈哈哈

浙公网安备 33010602011771号