码迷,mamicode.com
首页 > 系统相关 > 详细

Shell分发系统

时间:2018-01-27 00:42:05      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:password   strong   bar   expec   end   local   syn   --   str   

rsync.expect

#!/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

/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分发系统

标签:password   strong   bar   expec   end   local   syn   --   str   

原文地址:http://blog.51cto.com/juispan/2065683

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!