请教一个脚本编程问题
if循环语句可以按照下面的写法吧?太久没用了,谢谢!
#!/bin/bash
#set -x
i2=`curl -s 20.40.30.57:9100/metrics |egrep "^check_ok" |awk '{print $2}'`
if [ $i2 == "1" ]
then
echo "1"
else
sleep 60
i3=`curl -s 20.40.30.57:9100/metrics |egrep "^check_ok" |awk '{print $2}'`
if [ $i3 == "1" ]
then
echo "1"
else
sleep 60
i4=`curl -s 20.40.30.57:9100/metrics |egrep "^check_ok" |awk '{print $2}'`
fi
if [ $i4 == "1" ]
then
echo "1"
else
sleep 60
i5=`curl -s 20.40.30.57:9100/metrics |egrep "^check_ok" |awk '{print $2}'`
fi
if [ $i5 == "1" ]
then
echo "1"
else
sleep 60
i6=`curl -s 20.40.30.57:9100/metrics |egrep "^check_ok" |awk '{print $2}'`
fi
if [ $i6 == "1" ]
then
echo "1"
else
echo "0"
fi
fi