/usr/local/bin/xsync
#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
pcount=$#
if((pcount==0)); then
echo no args;
exit;
fi
#2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname
#3 获取上级目录到绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir
#4 获取当前用户名称
user=`whoami`
#5 循环
for((host=2; host<5; host++)); do
#echo $pdir/$fname $user@z0$host:$pdir
echo --------------- z0$host ----------------
rsync -rvl $pdir/$fname $user@z0$host:$pdir
done
cat /usr/local/bin/xcall
#!/bin/bash
pcount=$#
if((pcount==0));then
echo no args;
exit;
fi
echo -------------localhost----------
$@
for((host=2; host<=4; host++)); do
echo ----------z0$host $@---------
ssh z0$host $@
done