标签:nbsp expect roo dex 分发 end 构建 word rsync.sh
该脚本实现批量同步文件
[root@localhost ~]# cat rsync.expect #!/usr/bin/expect set passwd "root" set host [lindex $argv 0] set file [lindex $argv 1] spawn rsync -av --file-from=$file / root@$host:/ expect { "yes/no" { send "yes\r" } "password:" { send "$passwd\r" } } expect eof
[root@localhost ~]# cat rsync.sh for ip in `cat ip.list` do echo $ip ./rsync.expect $ip list.txt done
[root@localhost ~]# cat ip.list 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5
[root@localhost ~]# chmod a+x rsync.expect [root@localhost ~]# chmod a+x rsync.sh [root@localhost ~]# sh rsync.sh
标签:nbsp expect roo dex 分发 end 构建 word rsync.sh
原文地址:http://www.cnblogs.com/pzk7788/p/7198530.html