rsync.expect
#!/usr/bin/expect set passwd "123456" ##建议用密钥,防止口令泄露 set host [lindex $argv 0] set file [lindex $argv 1] spawn rsync -avR --files-from=$file / [email protected]$host:/ expect { "yes/no" { send "yes\r"} "password:" { send "$passwd\r" } } expect eof
list.txt
/tmp/1.txt /usr/local/sbin/2.sh
ip.list
192.168.89.134 192.168.87.167
rsync.sh
#!/bin/bash for ip in `cat /tmp/ip.list` do echo $ip ./rsync.expect $ip /tmp/list.txt done
除了文件的分发外,还可以批量执行命令。
原文地址:http://blog.51cto.com/juispan/2065683
时间: 2024-10-16 07:29:50