Last active
April 20, 2018 08:16
-
-
Save jwangac/35fe293eb1ecf2ad5209328d5a3b0a6c to your computer and use it in GitHub Desktop.
Autologin script for BUAA.
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/sh | |
| CURL=/usr/bin/curl | |
| if [ $# -ne 2 ]; then | |
| echo "Usage: $0 <username> <password>" | |
| exit 1 | |
| fi | |
| check() | |
| { | |
| $CURL -4 -I -L -m 1 -o /dev/null -s -w "%{http_code}" $1 | |
| } | |
| login() | |
| { | |
| url="https://gw.buaa.edu.cn/srun_portal_phone.php" | |
| data="action=login&ac_id=22&username=$1&password=$2" | |
| $CURL -4 -o /dev/null -s $url -d $data | |
| } | |
| if [ $(check "http://google.cn/generate_204") -ne 204 ]; then | |
| if [ $(check "http://google.cn/generate_204") -ne 204 ]; then | |
| if [ $(check "http://gw.buaa.edu.cn") -eq 200 ]; then | |
| login $1 $2 | |
| fi | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment