我想在下面的脚本中更改全局变量status
的值,但我不知道这有什么问题。
status="alive";
for i in (*code here*)
do
ping -c3 (*host modified by the code*) > /dev/null
if [ $? -eq 0 ]
then
status="alive";
else
status="dead";
fi
if [ "$status" == "alive" ]
then
(*code here*)
fi
此状态变量用于检查主机是否已关闭,如果主机未关闭,则执行ping操作。否则。
最后一个if语句是否正常工作???请告诉我哪里有错误。先谢谢!!
问题已解决!!!!
答案 0 :(得分:0)
status="alive";
for i in (*code here*)
do
ping -c3 (*host modified by the code*) > /dev/null
if [ $? -eq 0 ]
then
status="alive";
else
status="dead";
fi
if [ "$status" == "alive" ]
then
(*code here*)
fi
done #<-- this was missing!!