Skip to content

Instantly share code, notes, and snippets.

@DAP-DarkneSS
Created March 10, 2012 17:11
Show Gist options
  • Save DAP-DarkneSS/2012150 to your computer and use it in GitHub Desktop.
Save DAP-DarkneSS/2012150 to your computer and use it in GitHub Desktop.
Tool to get traffic statistic from Internet provider Vesso-Bel (BY) using wget [v.0.1]
#!/bin/bash
HLPARG=--help
# VRBARG=--verbose
TMPDIR=/tmp/vessobel
ERR='" либо eMail="" не найден'
HTM=vessobel.html
# VRB=1
HLPMSG="Tool to get traffic statistic from Internet provider Vesso-Bel (Belarus).\n\n\
Usage: vessobel.sh [LOGIN]\n\nOutput: [Used in MB] / [Free in MB] | [Total in GB]\n\n\
Options:\n\t--help\t\tprint this help.\n\n\
Mail bug reports and suggestions to <dap.darkness at gmail dot com>."
if [ "`echo $@ | grep -o -- $HLPARG`" == $HLPARG ]
then
echo -e $HLPMSG
else
# if [ "`echo $@ | grep -o -- $VRBARG`" == '' ]
# then
# VRB=0
# stty -echo
# fi
mkdir -p $TMPDIR
cd $TMPDIR
wget -q 'http://stat.vessobel.by/cgi-bin/BILinfon.cgi?Login='$1
iconv -f cp1251 -t utf-8 BILinfon.cgi\?Login=$1 > $HTM
if [ "`grep -o "$ERR" $HTM`" == "$ERR" ]
then
OUT='Wrong login!'
else
TTLGB=`grep ГБ $HTM | awk '{ print $1 }'`
let 'TTLMB=TTLGB*1024'
USED=`grep мб $HTM | awk '{ print $6 }' | grep -o '[0-9]*'`
let 'FREE=TTLMB-USED'
OUT=$USED' / '$FREE' | '$TTLGB'GB'
fi
# if [ "$VRB" == "0" ]
# then
# stty echo
# fi
echo $OUT
cd ..
rm -rf $TMPDIR
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment