命令行登陸校園網
今天使用學校服務器,總是無法安裝軟件,提示 cannot find a valid baseurl for repo:base/7/x86_64
嘗試了無數種方法總是無法解決
後來發現是服務器只在內網,不能訪問外網導致的。
因此需要使服務器訪問外網,但是服務器只有命令行,因此需要讓服務器用命令行登陸外網。
登陸校園網
curl 'http://210.28.18.3' --data "DDDDD=student_id&upass=password&0MKKey="
# student_id:學號
# password :密碼
退出校園網
curl http://210.28.18.3/F.htm
寫成shell腳本
每次都要輸入命令是很麻煩的,因此寫成shell腳本就很方便了。
登陸:
vim Login.sh #創建登陸文件 寫入下面的內容
chmod 777 Login.sh #給運行權限
#!/bin/bash
curl 'http://210.28.18.3' --data "DDDDD=6191905032&upass=131513&0MKKey=" > report.txt
登出:
vim Logout.sh #創建登陸文件 寫入下面的內容
chmod 777 Logout.sh #給運行權限
#!/bin/bash
curl http://210.28.18.3/F.htm > report.txt
然後,再次需要訪問外網時,執行下面的命令就可以了
./Login.sh #登陸校園網
./Logout.sh #登出校園網