Skip to content

Instantly share code, notes, and snippets.

@zapstar
Created September 3, 2014 04:12
Show Gist options
  • Save zapstar/ee6fa34d8a841bf646b1 to your computer and use it in GitHub Desktop.
Save zapstar/ee6fa34d8a841bf646b1 to your computer and use it in GitHub Desktop.
Simple shell script to check whether a website is down only for me or everyone else. Uses curl and isup.me service.
# Simple script to figure out whether a site is up or not
TOOL_SITE="http://www.isup.me/"
if [ $# -ne 1 ]
then
echo "Incorrect arguments specified"
exit 1
fi
# Check if curl is installed, if not exit
dpkg -s curl | grep "install ok installed" 1>/dev/null
if [ $? -ne 0 ]
then
echo "curl is not installed. Install via 'sudo apt-get install curl'"
exit 1
fi
# Make an HTTP request to our tool site
# grep for "It's just you... <site> is up"
curl "$TOOL_SITE$1" 2>/dev/null | grep "just you.*is up" 1>/dev/null
if [ $? -eq 0 ]
then
echo "$1 is up"
else
echo "$1 is down"
fi
@esirotinski
Copy link

Hey, you can skip the grep at line 12 and probably at line 21.

$ dpkg -s curl
dpkg-query: package 'curl' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.

$ echo $?
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment