一键登录重庆大学校园网的简易脚本,脚本通过向 http://login.cqu.edu.cn:801/eportal/portal/login 接口发送请求完成登陆。
cqu-login.ps1:适用于 Windows 的 PowerShell 脚本,右键运行。cqu-login.sh:适用于 Linux 的 Bash 脚本,指令运行,结合crontab可完成守护。
运行前请先修改脚本中的账号、密码和网卡名称。
由于 Windows 特性,请使用 GB2312 编码打开和保存,避免出现中文乱码。
# ======== Configuration ========
$username = "Please enter your username here"
$password = "Please enter your password here"
$interface = "以太网"
# ===============================# ======== Configuration ========
USERNAME="Please enter your username here"
PASSWORD="Please enter your password here"
INTERFACE="eth0"
# ===============================Linux 可使用 crontab 做简单守护,每分钟探测一次连通性,适合挂到路由器上的场景:
* * * * * curl --connect-timeout 10 https://www.baidu.com || bash /path/to/your/cqu-login.shWindows 没有比较优雅的守护方式,得创建计划任务,此处省略。