Skip to content

Instantly share code, notes, and snippets.

@AlephAlpha
Last active April 15, 2018 13:10
Show Gist options
  • Save AlephAlpha/625c5643056588df8be2bd75ab64b4a0 to your computer and use it in GitHub Desktop.
Save AlephAlpha/625c5643056588df8be2bd75ab64b4a0 to your computer and use it in GitHub Desktop.
用Mathematica写了个TUNet登录脚本
#!/usr/bin/env wolframscript
(*_*)
(*命令行参数有两个以上时,前两个分别为用户名和密码*)
(*命令行参数只有一个时,退出登录*)
(*没有命令行参数,显示登录状态*)
Print@URLExecute["http://net.tsinghua.edu.cn/do_login.php",
$ScriptCommandLine /.
{{_, username_, password_, ___} :>
{"action" -> "login",
"username" -> username,
"password" ->
"{MD5_HEX}" <> Hash[password, "MD5", "HexString"],
"ac_id" -> "1"},
{_, _} :> {"action" -> "logout"},
_ :> {"action" -> "check_online"}}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment