Last active
December 18, 2015 11:38
-
-
Save z3cka/5776749 to your computer and use it in GitHub Desktop.
A silly little bash script for checking if a site is up. usage: ./isu.sh sitetocheck.com
This file contains 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
#!/bin/sh | |
siteResponse=`curl -s -I $1 | grep HTTP/1.1 | awk {'print $2'}` | |
if [ $siteResponse = 200 ]; then | |
echo "Looks like your site responded with a" $siteResponse "and is fine, be happy!" | |
else | |
echo "rut ro! Looks like your site responded with a" $siteResponse "and that's not right, go fix it!" | |
case $siteResponse in | |
301 ) | |
echo "aaah, it's a 301, no prob right?";; | |
500 ) | |
echo $2 "is the email I'm going to try to send to." | |
echo "yikes! 500! Maybe restart mysql... but I'm just guessing" | mail -s "500 error @ '$1'" "'$2'";; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage example: