Last active
August 29, 2015 13:57
-
-
Save tommy351/9503105 to your computer and use it in GitHub Desktop.
TKU WiFi Utilities
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 | |
function find_gateway(){ | |
gateway=$(netstat -nr | grep "default" | awk "{print \$2}") | |
if [[ "$(grep "163.13." <<< $gateway)" == "" ]]; then | |
echo "Gateway $gateway is not a valid TKU IP!" | |
exit 1 | |
fi | |
} | |
command=$1 | |
if [[ $command == "login" ]]; then | |
find_gateway | |
read -p "Username: " username | |
read -s -p "Password: " password | |
echo "" | |
result=`curl -s -d "username=$username&userpwd=$password&login=login" "http://$gateway/cgi-bin/ace_web_auth.cgi"` | |
unset username | |
unset password | |
if [[ "$(grep "/login.php" <<< $result)" ]]; then | |
echo "Login failed" | |
exit 1 | |
else | |
echo "Login success" | |
exit 0 | |
fi | |
elif [[ $command == "logout" ]]; then | |
find_gateway | |
result=`curl -s "http://$gateway/cgi-bin/ace_web_auth.cgi?logout"` | |
echo "You have logged out" | |
exit 0 | |
elif [[ $command == "info" ]]; then | |
find_gateway | |
open "http://$gateway/login_online_detail.php" | |
else | |
echo "Commands:" | |
echo " login - Log in" | |
echo " logout - Log out" | |
echo " info - Check connection info" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment