Skip to content

Instantly share code, notes, and snippets.

@actuallymentor
Last active May 22, 2019 10:31
Show Gist options
  • Save actuallymentor/39700b2fdec22a149f13a1cf57426ad1 to your computer and use it in GitHub Desktop.
Save actuallymentor/39700b2fdec22a149f13a1cf57426ad1 to your computer and use it in GitHub Desktop.
curl based website up function
#!/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