Skip to content

Instantly share code, notes, and snippets.

@zhanghai
Last active August 29, 2015 14:01
Show Gist options
  • Save zhanghai/d0a6f5e8c4bf1b439405 to your computer and use it in GitHub Desktop.
Save zhanghai/d0a6f5e8c4bf1b439405 to your computer and use it in GitHub Desktop.
Login script for ZJUWLAN
#!/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