Skip to content

Instantly share code, notes, and snippets.

@kitusmark
Created January 21, 2016 14:00
Show Gist options
  • Save kitusmark/a1418c1bebe32919741a to your computer and use it in GitHub Desktop.
Save kitusmark/a1418c1bebe32919741a to your computer and use it in GitHub Desktop.
Checks for internet connection, prints the status on the terminal and save a status variable for later.
#!/bin/bash
#Checks for internet connection, prints the status on the terminal and save a status variable for later.
wget -q --tries=5 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
STATUS=true
echo "ONLINE
else
STATUS=false
echo "OFFLINE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment