Skip to content

Instantly share code, notes, and snippets.

@Tantas
Last active August 29, 2015 14:04
Show Gist options
  • Save Tantas/0646fc06de60e3f80ec6 to your computer and use it in GitHub Desktop.
Save Tantas/0646fc06de60e3f80ec6 to your computer and use it in GitHub Desktop.
Acanac ISP Health Check
#!/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