Last active
August 29, 2015 14:04
-
-
Save Tantas/0646fc06de60e3f80ec6 to your computer and use it in GitHub Desktop.
Acanac ISP Health Check
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/bash | |
#=============================================================================== | |
# from https://gist.github.com/Tantas/5412d1e319c69d0d56ab | |
stripEncodedLineEndings() { | |
# stripEncodedLineEndings <string> | |
local stripFirstPart="${1//%0D}" | |
echo "${stripFirstPart//%0A}" | |
} | |
urlencode() { | |
# urlencode <string> | |
local length="${#1}" | |
for (( i = 0; i < length; i++ )); do | |
local c="${1:i:1}" | |
case $c in | |
[a-zA-Z0-9.~_-]) printf "$c" ;; | |
*) printf '%%%02X' "'$c" | |
esac | |
done | |
} | |
urldecode() { | |
# urldecode <string> | |
local stripedOfLineTerminators=$(stripEncodedLineEndings $1) | |
local url_encoded="${stripedOfLineTerminators//+/ }" | |
printf '%b' "${url_encoded//%/\x}" | |
} | |
#=============================================================================== | |
# Colors for pretty output | |
green='\x1B[0;32m' | |
endColor='\x1B[0m' | |
echo -e "\n__ACANAC ISP Health Check__" | |
echo -e "${green}High Speed Cable Service Health${endColor}" | |
result=$(curl -s -I https://www.acanac.com/getstatus.php | grep Set-Cookie) | |
result=${result##*Set-Cookie\: NetStatus=} | |
result=${result%%\;*} | |
echo -e $(urldecode $result) "\n" | |
echo -e "${green}DSL Service Health${endColor}" | |
result=$(curl -s -I https://www.acanac.com/getstatus1.php | grep Set-Cookie) | |
result=${result##*Set-Cookie\: NetStatus1=} | |
result=${result%%\;*} | |
echo -e $(urldecode $result) "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment