fork自https://coding.net/u/huxiaofan1223/p/jxnu_srun/git
作者已经毕业,很难再更新代码了。如果校园网有变动,并且你有好的解决方案,还请提个pr哈。非常感谢~~ o( ̄▽ ̄)ブ
北京理工大学深澜校园网登录python脚本,可用于任何支持python的设备的网络命令行登录或命令行登录。
详细文档见:深澜校园网登录的分析与python实现-北京理工大学版
文件 | 说明 |
---|---|
BitSrunLogin/ | 深澜登录函数包 |
demo.py | 登录示例脚本 |
always_online.py | 在线监测脚本,如果监测到掉线则自动重连 |
always_online.py可采用nohup
命令挂在后台:
nohup python always_online.py --username xxx --password xxx &
参考 https://zhuanlan.zhihu.com/p/523973210
- 创建一个sh脚本,命名为
run_bit_login.sh
,其内容为:
nohup python3 /abs/path/to/always_online.py --username xxx --password xxx
- 设置脚本权限:
chmod +x run_bit_login.sh
- 创建相应的服务”
sudo vim /lib/systemd/system/bit_auto_login.service
其内容为:
[Unit]
Description=Auto login into the internet in BIT
# the dependency
# Wants=network-online.target
# After=network-online.target
After=multi-user.target
[Service]
Type=simple
ExecStart=bash /abs/path/to/run_bit_login.sh
# or we can start this service direcly with commandline, no bash file required
# ExecStart=nohup python3 /abs/path/to/always_online.py --username xxx --password xxx
ExecStart=bash /abs/path/to/run_bit_login.sh
ExecReload=/bin/kill -HUP $MAINPID
RestartSec=5s
Restart=on-failure
[Install]
WantedBy=multi-user.target
- 添加开机自启动:
systemctl enable scratch.service