Last active
May 22, 2019 10:31
-
-
Save actuallymentor/39700b2fdec22a149f13a1cf57426ad1 to your computer and use it in GitHub Desktop.
curl based website up function
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
#!/usr/bin/zsh | |
RED="\033[0;31m" | |
GREEN="\033[0;32m" | |
YELLOW="\033[1;33m" | |
NC="\033[0m" # No Color | |
# Called as islive url title | |
function isLive() { | |
if curl -Is $1 2>&1 | grep -q 'HTTP.* 200'; then | |
echo $GREEN 'UP: ' "${2:-$1}" | |
else | |
echo $RED 'DOWN: ' "${2:-$1}" | |
fi | |
# curl -Is $1 2>&1 | grep -q 'HTTP.* 200' && echo $GREEN 'LIVE' $1 || echo $RED 'DOWN' $1 | |
# Reset terminal color | |
echo $NC | |
} | |
isLive 'https://www.google.com/' 'Google' | |
isLive 'https://www.doesnotexistatall123456789.com/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment