Shell分发系统

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell分发系统相关的知识,希望对你有一定的参考价值。

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


除了文件的分发外,还可以批量执行命令。


以上是关于Shell分发系统的主要内容,如果未能解决你的问题,请参考以下文章