Skip to content

Instantly share code, notes, and snippets.

@ninehills
Created November 23, 2010 04:58
Show Gist options
  • Save ninehills/711280 to your computer and use it in GitHub Desktop.
Save ninehills/711280 to your computer and use it in GitHub Desktop.
网关登录脚本
#!/bin/bash
USER=user #账号
PASS=pass #密码
GATE=https://202.113.18.188
GATELOGOUT=https://202.113.18.188/F.htm #网关登出地址
if [ "$1" = "login" ];
then
EXIT=`curl -silent -k -d DDDDD=$USER -d upass=$PASS -d 0MKKey='登录 Login' $GATE | grep -c 'Msg=01'`
if [ 0 -ne $EXIT ]
then
echo -e "\E[1;31mWrong Username or Password!\E[0m"
exit
fi
exit
fi
if [ "$1" = "show" ];
then
LOGOUT=`curl -silent -k $GATE | grep -c '0MKKey'`
if [ 0 -ne $LOGOUT ]
then
echo -e "\E[1;31mNot Login\E[0m"
exit
fi
RESULT1=`curl -silent -k $GATE | grep 'uid='`
RESULT2=`curl -silent -k $GATE | grep 'fee='`
# 账号ID
UserID=`echo $RESULT1 | awk -F\' '{print $2}'`
#登录IP
LoginIP=`echo $RESULT1| awk -F\' '{print $6}'`
# 本账号已使用时间,单位min
TIME=`echo $RESULT2 | awk -F\' '{print $2}'`
# 本帐号已使用流量,单位MB
FLOW=`echo $RESULT2 | awk -F\' '{print $4/1024}'`
# 当前余额,单位RMB
FEE=`echo $RESULT2 | awk -F\' '{print $6/10000}'`
echo '========================================'
echo '您的账号为' $UserID
echo '登录IP地址为' $LoginIP
echo '帐号已使用时间为 '$TIME' 分钟'
echo '已使用流量为 '$FLOW' MB'
echo '当前余额为 '$FEE' 元'
echo '========================================'
exit
fi
if [ "$1" = "logout" ];
then
is_logout=`curl -silent -k $GATELOGOUT | grep -c 'Msg=14'`
exit
fi
echo 'gateway.sh command'
echo '-------------------'
echo 'login,show,logout'
echo '-------------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment