Hi,
I Have to check two condition in while loop every 2 minutes. while loop is accompanied with number of times it will check.Please help in putting the two condition in while loop as appropriate.
z= input value,
A=1
while [ $A -le $z ]
do
1.check the file output,if the file output is N then keep on checking till the count every 2minutes.)sleep is used here with the count expr for A.
2.if not then check the output is Y, if yes then execute main script and come out.
sleep 120
A=`expr $A + 1`
done
This is one of the ways to write an if-block in a shell scrip
if [ expr ]
then
statements
fi
From what I understand, one condition is sufficient.
while [ $A -le $z ]
do
if [ $(cat file) == "Y" ] # We're cat-ing the file only because we know it contains one character only. Otherwise this is a bad trick
then
<execute_main_script>
fi
sleep 120
A=`expr $A + 1`
done
A break
can make sense here
while [ $A -le $z ]
do
read line < file # efficiently read the first line
if [ "$line" = "Y" ]
then
/path/to/main_script
break # break the loop
fi
sleep 120
A=`expr $A + 1`
done