Created
September 3, 2014 04:12
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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