I am trying to check a string that is output from a program, if the string matches a certain content, the while-loop will stop the program. At the same time, I need to count how many times the program has run:
x = "Lookup success" # this is supposed to be the output from the program
INTERVAL=0 # count the number of runs
while ["$x" != "Lookup failed"] # only break out the while loop when "Lookup failed" happened in the program
do
echo "not failed" # do something
$x = "Lookup failed" # just for testing the break-out
INTERVAL=(( $INTERVAL + 10 )); # the interval increments by 10
done
echo $x
echo $INTERVAL
But this shell script is not working, with this error:
./test.sh: line 9: x: command not found
./test.sh: line 12: [[: command not found
Could someone help me please? I appreciate your help.