I have a small bash script I'm writing to check internet connection on my computer and it contains two boolean variables that change over time. My question is...how do I compare the two?
The code I have is (I thought) pretty straight forward, but it's constantly giving me an "internet OFF" which I know isn't right.
I've tested it in the linux terminal, and I realize that my comparison between booleans isn't correct, I just can't seem to figure it out.
NOTE: I can make the program work if I extend the if/then statement...I just want to know how to make it work the way it's set up below. I don't understand why the boolean variable comparison doesn't work this way.
Thanks for the help!
CODE:
prevStatus=false;
newStatus=true;
while true;
do
ping -q -c1 www.google.com;
pingStatus=$?;
if (($pingStatus == 0));
then newStatus=true;
else newStatus=false;
fi;
if (($newStatus != $prevStatus)) && (($newStatus == true));
then echo "internet OFF" >> logfile;
else echo "internet ON" >> logfile;
fi;
prevStatus=$newStatus
sleep 60s;
done;