I'm writing a loop that checks whether a connection has been established.
I'm doing
ping -c 1 8.8.8.8
while [ $? -ne 0 ] do
sleep 0.5
ping -c 1 8.8.8.8
done
Now I'm not sure how this works, if the ping request got blocked on its way out (iptables or other) the command and the script will hang indefinitely. What I want is to stop waiting for a reply after 1 sec and send a new request. That until I get a reply faster than 1sec, the $? is equal to 0 and it breaks the loop.