Last active
August 29, 2015 14:01
-
-
Save zhanghai/d0a6f5e8c4bf1b439405 to your computer and use it in GitHub Desktop.
Login script for ZJUWLAN
This file contains hidden or 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 | |
USERNAME= | |
PASSWORD= | |
echo "Kicking other clients offline..." | |
response=$(curl 'https://net.zju.edu.cn/rad_online.php' -H 'Content-Type: application/x-www-form-urlencoded' -d "action=auto_dm&username=$USERNAME&password=$PASSWORD" -s) | |
if [[ "$response" != "ok" ]]; then | |
echo "$response" | |
exit 1 | |
fi | |
echo "Logging in..." | |
response=$(curl 'https://net.zju.edu.cn/cgi-bin/srun_portal' -H 'Content-Type: application/x-www-form-urlencoded' -d "action=login&username=$USERNAME&password=$PASSWORD&ac_id=3&type=1&is_ldap=1&local_auth=1" -s) | |
if [[ "$response" = *"help.html"* ]] || [[ "$response" = *"login_ok"* ]]; then | |
echo "Login successful." | |
else | |
echo "$response" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment