shell读取文件,并循环远程执行
#!/bin/bash
if [ "$1" = local ];then
do something
exit
fi
while read host hostname
do
scp $0 root@$host:/tmp/
echo $host
ssh root@$host /tmp/$0 local </dev/null
let count+=1
done < /root/.ssh/hosts
#!/bin/bash
if [ "$1" = local ];then
do something
exit
fi
while read host hostname
do
scp $0 root@$host:/tmp/
echo $host
ssh root@$host /tmp/$0 local </dev/null
let count+=1
done < /root/.ssh/hosts