rsync.expect
|
1
2
3
4
5
6
7
8
9
10
|
#!/usr/bin/expect
set
passwd
"123456"
##建议用密钥,防止口令泄露
set
host [lindex $argv 0]
set
file
[lindex $argv 1]
spawn
rsync
-avR --files-from=$
file
/ root@$host:/
expect {
"yes/no"
{ send
"yes\r"
}
"password:"
{ send
"$passwd\r"
}
}
expect eof
|
list.txt
|
1
2
|
/tmp/1.txt
/usr/local/sbin/2.sh
|
ip.list
|
1
2
|
192.168.89.134
192.168.87.167
|
rsync.sh
|
1
2
3
4
5
6
|
#!/bin/bash
for
ip
in
`
cat
/tmp/ip
.list`
do
echo
$ip
.
/rsync
.expect $ip
/tmp/list
.txt
done
|
除了文件的分发外,还可以批量执行命令。
本文转自Grodd51CTO博客,原文链接:http://blog.51cto.com/juispan/2065683,如需转载请自行联系原作者