#!/bin/bash
ip="172.16.1.113"
command="rsync -avu /root/test $ip:/root/"
expect -c "
spawn $command;
expect {
\"Are you sure you want to continue connecting (yes/no)?\" {send \"yes\r\"; exp_continue}
\"172.16.1.113's password:\" {send \"1q2w3e4R!\r\"; exp_continue}
}
"
转载于:https://blog.51cto.com/wemux/1528512