Skip to content

Instantly share code, notes, and snippets.

@kithokit
Created March 7, 2014 04:41
Show Gist options
  • Save kithokit/9405358 to your computer and use it in GitHub Desktop.
Save kithokit/9405358 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
MAXRETRY=50
count=0
ping -W3 -c1 www.google.com > /dev/null 2>&1
while [ $? -ne 0 ]; do
#statements
if [ "$count" = "$MAXRETRY" ]; then
echo "No network found outside to Internet"
exit 1
fi
echo "Retry the network times: $count"
count=$((count + 1))
sleep 1
ping -W3 -c1 www.google.com > /dev/null 2>&1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment