Code Monkey home page Code Monkey logo

bit-srun-login-script's Introduction

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 &

linux 开机自启动

参考 https://zhuanlan.zhihu.com/p/523973210

  1. 创建一个sh脚本,命名为run_bit_login.sh,其内容为:
nohup python3 /abs/path/to/always_online.py --username xxx --password xxx
  1. 设置脚本权限:
chmod +x run_bit_login.sh
  1. 创建相应的服务”
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
  1. 添加开机自启动:
systemctl enable scratch.service

bit-srun-login-script's People

Contributors

liuqk3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.