Skip to content

Instantly share code, notes, and snippets.

@DAP-DarkneSS
Created March 24, 2012 09:53
Show Gist options
  • Save DAP-DarkneSS/2180725 to your computer and use it in GitHub Desktop.
Save DAP-DarkneSS/2180725 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.3]
#!/bin/zsh
HLPARG=--help
KDEARG=--kde
LOGERR='" либо eMail="" не найден'
IPERR="пулу"
OUT='Unknown error!'
if [ -n "`echo $@ | grep -o -- $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 -s -f cp1251 -t utf-8`"
if [ -n "`echo "$IN" | grep -o "$IPERR"`" ]
then
OUT='Wrong IP address!'
else
if [ -n "`echo "$IN" | grep -o "$LOGERR"`" ]
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
fi
if [ -n "`echo $@ | grep -o -- $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