我想问一下如何在多台服务器上执行命令?
if [ $exitstatus = 0 ]; then
echo "User selected Ok"
serv=`hostname`
for SERVER in $(cat $PWD/$ADD_KEY); do
ssh -t -o StrictHostKeyChecking=no root@$SERVER <<'EOF'
cca=`cat $RDIR | grep $keyy`
if [[ "$cca" == "$keyy" ]]; then
echo "OK"
else
echo "NOK"
fi
EOF
#"hostname && cat $RDIR | grep $keyy " << 'EOF'
#EOF
done >> temp.txt
fi
我尝试使用:
for SERVER in $(cat $PWD/$ADD_KEY); do
ssh -t -o StrictHostKeyChecking=no root@$SERVER '
cca=`cat $RDIR | grep $keyy`
if [[ "$cca" == "$keyy" ]]; then
echo "OK"
else
echo "NOK"
fi
'
没有工作,三天后我试图弄清楚怎么做,请帮助我