同步文件到其它服务器上

时间:2021-10-25 23:44:38

if[! -f ip.txt];then

exit 

fi

if[-z "$1"];then

exit

fi

count=`cat ip.txt|wc -l`

rm -rf ip.txt.swp

i=0

while((i<$count))

do

i=`expr $i +1`

sed"${i}s/^/&${i} /g" ip.txt>>ip.txt.swp

IP=`awk -v I="$i" '{if(I==$1)print $2}' ip.txt.swp`

scp -r $1 root@${IP}:$2

#ssh -q -l root $IP "

etho -e '-------------\nThe $IP Exec

Command : $* sussess !';sleep 2"

#rsync -ap --delete $1 root@${IP}:$2

done