Skip to content

Instantly share code, notes, and snippets.

@DAP-DarkneSS
Created March 10, 2012 21:13
Show Gist options
  • Save DAP-DarkneSS/2013219 to your computer and use it in GitHub Desktop.
Save DAP-DarkneSS/2013219 to your computer and use it in GitHub Desktop.
Tool to get traffic statistic from Internet provider Vesso-Bel (BY) using curl [v.0.2.0]
#!/bin/bash
HLPARG=--help
TMPDIR=/tmp/vessobel
ERR='" либо eMail="" не найден'
HTM=vessobel.html
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
IN="`curl -s 'http://stat.vessobel.by/cgi-bin/BILinfon.cgi?Login='$1 | iconv -f cp1251 -t utf-8`"
if [ "`echo "$IN" | grep -o "$ERR"`" == "$ERR" ]
then
OUT='Wrong login!'
else
TTLGB=`echo "$IN" | grep ГБ | awk '{ print $1 }'`
let 'TTLMB=TTLGB*1024'
USED=`echo "$IN" | grep мб | awk '{ print $6 }' | grep -o '[0-9]*'`
let 'FREE=TTLMB-USED'
OUT=$USED' / '$FREE' | '$TTLGB'GB'
fi
echo $OUT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment