Skip to content

Instantly share code, notes, and snippets.

@DAP-DarkneSS
Created March 12, 2012 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DAP-DarkneSS/2020886 to your computer and use it in GitHub Desktop.
Save DAP-DarkneSS/2020886 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.1.1]
#!/bin/bash
HLPARG=--help
KDEARG=--kde
ERR='" либо eMail="" не найден'
OUT='Unknown error!'
if [ "`echo $@ | grep -o -- $HLPARG`" == $HLPARG ]
then
OUT="Tool to get traffic statistic from Internet provider Vesso-Bel (Belarus).\n\n\
Usage: vessobel.sh [LOGIN] [OPTION]\n\n\
Output: [Used in MB] / [Free in MB] | [Amount of payment in belarusian rubles]\n\n\
Options:\n\t--help\t\tprint this help.\n\
\t--kde\t\toutput to KDE system notifications.\n\n\
Mail bug reports and suggestions to <dap.darkness at gmail dot com>."
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
TOTAL=`echo "$IN" | grep ГБ`
MINPRICE=`echo "$TOTAL" | awk '{ print $2 }' | grep -o '[0-9]*'`
TOTAL=`echo "$TOTAL" | awk '{ print $1 }'`
let 'TOTAL=TOTAL*1024'
USED=`echo "$IN" | grep мб | awk '{ print $6 }' | grep -o '[0-9]*'`
let 'FREE=TOTAL-USED'
PRICE=`echo "$IN" | grep Отработано | grep -o '[0-9]*' | tr -d "\n"`
if [ "$MINPRICE" -gt "$PRICE" ]
then
PRICE=$MINPRICE
fi
OUT=$USED' MB / '$FREE' MB | '$PRICE' BYR'
fi
fi
if [ "`echo $@ | grep -o -- $KDEARG`" == $KDEARG ]
then
kdialog --title "Vesso-Bel" --passivepopup "$OUT"
else
echo -e "$OUT"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment