Created
March 11, 2018 05:51
-
-
Save thinkycx/2b4323353147e26ba9e97a6e3eee649e to your computer and use it in GitHub Desktop.
bash script to connect to bupt gateway
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# author: thinkycx | |
# sudo ln -s ~/bupt-gateway.sh /usr/bin/bupt-gateway && source ~/.zshrc | |
user=XXX | |
password=XXX | |
URL="http://10.3.8.211" | |
HTTP_CODE=$(curl -s -IL $URL | head -n 1 | grep -o 200) | |
CODE=200 | |
if [ $HTTP_CODE -eq 200 ];then | |
echo "Welcome to bupt!" | |
echo "connecting..." | |
HTTP_CODE2=$(curl $URL -d "DDDDD=$user&upass=$password&savePWD=0&0MKKey=" -D- -o/dev/null -s | head -n1 |grep -o 200) | |
if [ $HTTP_CODE2 -eq 200 ];then | |
echo "OK" | |
fi | |
else | |
echo "You are not in bupt!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
遇到了个curl 请求时的错误:
参考:http://www.jackxiang.com/post/6849/
其他: