Aggancia questa barra allo schermo |  Disattiva gli effetti grafici


Auto-disconnesione per abbonamenti a volume

Oggi, 12/02/2009, mi sono attivato la promozione "Naviga 3" con la quale si hanno a disposizione 50MB al giorno per 30 giorni. script

Com'è intuibile, oltre il raggiungimento dei 50MB verrebbe applicata la normale tariffazione svuotando il credito della sim prima di rendersene conto.
Per ovviare a questo inconveniente, anche grazie all'aiuto degli amici di slacky.eu, ho scritto 2 script, che possono essere sfruttati per esempio con kppp, che killano pppd al raggiungimento dei 50MB:

killpppd.sh

# (C) 2009, Andrea Peluso.

expr $1 \+ 0 1> /dev/null
TEST=$?
if [ $# -ne 1 -o $TEST -ne 0 ]; then
  echo -e "Uso: $0 [limite in MB]\n"
  echo "Script di auto-disconnessione per abbonamenti a volume."
  echo -e "(C) 2009, Andrea Peluso.\n"
  exit 1
fi
DATE=$(date +%Y%m%d)
echo $DATE > /tmp/date.tmp
BYTEBU=0
LIM=$(expr $1 \* 1000000)
if [ -r /tmp/$DATE ]; then
  BYTEBU=`expr $(cat /tmp/$DATE)`
  if [ "$BYTEBU" -ge "$LIM" ]; then
    kdialog --warningcontinuecancel "Oggi sono gia' stati consumati $(expr $BYTEBU / 1000000) MB ($(expr $BYTEBU / 1048576) MB).\nVuoi continuare comunque?" --title "KillPPP"
    if [ $? = 0 ]; then
      exit 0
    else sudo killall pppd
    fi
  fi
  kdialog --msgbox "Oggi sono gia' stati consumati $(expr $BYTEBU / 1000000) MB ($(expr $BYTEBU / 1048576) MB).\nTraffico residuo: `expr \( $LIM \- $BYTEBU \) / 1000000` MB (`expr \( $LIM \- $BYTEBU \) / 1048576` MB)." --title "KillPPP" &
fi
while [ true ]
do
  RX=`cat /sys/class/net/ppp0/statistics/rx_bytes`
  TX=`cat /sys/class/net/ppp0/statistics/tx_bytes`
  BYTETOT=$(expr $RX \+ $TX \+ $BYTEBU)
  if [ "$BYTETOT" -ge "$LIM" ]; then
    echo + >> /tmp/$DATE
    cat /sys/class/net/ppp0/statistics/rx_bytes >> /tmp/$DATE
    echo + >> /tmp/$DATE
    cat /sys/class/net/ppp0/statistics/tx_bytes >> /tmp/$DATE
    kdialog --yesno "Sono stati consumati $(expr $BYTETOT / 1000000) MB ($(expr $BYTETOT / 1048576) MB).\nVuoi terminare la connessione?" --title "KillPPP"
    if [ $? = 0 ]; then
      sudo killall pppd
    fi
    exit 0
  fi
  sleep 5
done
Scarica [.sh]    ...scaricato 141 volte, dimensione: 2 KB

savebyte.sh

# (C) 2009, Andrea Peluso.

expr $1 \+ 0 1> /dev/null
TEST=$?
if [ $# -ne 1 -o $TEST -ne 0 ]; then
  echo -e "Uso: ./killppp.sh [limite in MB]\n"
  echo "Script di auto-disconnessione per abbonamenti a volume."
  echo -e "(C) 2009, Andrea Peluso.\n"
  exit 1
fi
DATE=$(cat /tmp/date.tmp)
BYTEBU=0
LIM=$(expr $1 \* 1000000)
if [ -r /tmp/$DATE ]; then
  BYTEBU=`expr $(cat /tmp/$DATE)`
fi
echo + >> /tmp/$DATE
cat /sys/class/net/ppp0/statistics/rx_bytes >> /tmp/$DATE
echo + >> /tmp/$DATE
cat /sys/class/net/ppp0/statistics/tx_bytes >> /tmp/$DATE
RX=$(cat /sys/class/net/ppp0/statistics/rx_bytes)
TX=$(cat /sys/class/net/ppp0/statistics/tx_bytes)
BYTECUR=$(expr $RX \+ $TX)
BYTETOT=$(expr $RX \+ $TX \+ $BYTEBU)
kdialog --msgbox "Sono stati consumati:\n$(expr $BYTECUR / 1000000) MB ($(expr $BYTECUR / 1048576) MB) in questa sessione,\n$(expr $BYTETOT / 1000000) MB ($(expr $BYTETOT / 1048576) MB) in totale nella data odierna,\n`expr \( $LIM \- $BYTETOT \) / 1000000` (`expr \( $LIM \- $BYTETOT \) / 1048576` MB) rimasti." --title "KillPPP" &
rm /tmp/date.tmp
Scarica [.sh]    ...scaricato 152 volte, dimensione: 1 KB

Il primo va eseguito subito dopo l'avvenuta connessione e il secondo, subito prima della disconnessione; entrambi col limite del proprio abbonamento espresso in megabyte come opzione.

Per esempio:

/percorso/completo/killpppd.sh 50

e

/percorso/completo/savebyte.sh 50

...nel caso si abbiano 50 MB a disposizione.

Ho voluto pubblicarli qui, perché sono sicuro che serviranno a qualcuno.


Scritto da: Andrea Peluso (sya54M), . Aggiornato: .

Commenti

57 commenti

Содержанки

Jarrod

http://bitly.com/3dYLWBo

top erectile dysfunction products
bladder cancer erectile beefs function
can erectile dysfunction be cured naturally

erectile dysfunction medications

https://besterectiledysfunctionpills.com

bitly.com

Stacie

http://bitly.com/

Поиск

Athena

http://bit.ly/2GjJ46g

авито краснодар личный кабинет

Fidelia

https://panel007.club/

анонимные прокси россия

Megan

https://pro2bro.online

купить прокси socks5 приватные

Jan

https://pro2bro.online

анонимные прокси

Danny

https://pro2bro.online

прокси сервера россии

Jere

https://pro2bro.online

Музыка Онлайн vk

Anglea

https://vk.com/public71601430

site

Robbin

https://linktr.ee/janessa_brazil__flirt

site

Nydia

https://vopros-pdd.info/user/Stanleylasia/

site

Barbra

https://spitzchelny.ru/user/Stanleysap/

site

Adam

https://biznes-knigi.com/user/StanleyTaimi/

Crystalix Beneficios

Enid

https://healthpolicy.unm.edu/sites/default/files/webform/Crystalix-comprar-en-Per%C3%BA-2021.html

ketoslim turkey

Brianne

https://vinv.ucr.ac.cr/sites/default/files/webform/ketoslim-turkey-fr.html

suga norm turkey

Jada

https://vinv.ucr.ac.cr/sites/default/files/webform/suga-norm-turkey.html

heart strong turkey

Kandice

https://vinv.ucr.ac.cr/sites/default/files/webform/heart-strong-turkey.html

sites.google.com

Sibyl

https://sites.google.com/view/bioprostperu2021/BIOPROST-PERU

здесь

Ulysses

https://www.pinterest.com/pin/580753314454151230

свати 1 серія 5 сезон

Mohamed

https://bit.ly/svaty-7-sezon-1-seriya

rezka

Chana

https://bit.ly/hdrezka-hdrezka-hdrezka

Как смотреть сезонвар на телевизоре

Kraig

https://bit.ly/seasonvar-seasonvar-seasonvar

Кінокрад

Miranda

https://bit.ly/kinokrad-2021-kinokrad-kino-krad

смотреть

Louise

https://bit.ly/v-horoshem-kachestve-smotret-filmy-onlajn-film-online

смотреть

Bonnie

https://bit.ly/v-horoshem-kachestve-smotret-filmy-onlajn-film-online

Медиатор 2 сезон 6 серия

Craig

https://bit.ly/mediator-2-sezon-6-seriya

чики сериал

Maybelle

https://bit.ly/chiki-1-sezon-chiki-2-sezon-chiki-vse-seriy

бесплатно

Joann

https://bit.ly/besplatno-besplatno-online-besplatno

Просмотр

Cathryn

https://clck.ru/XEMJK

здесь

Meredith

https://bit.ly/3n03ODM

2828

Rodolfo

https://bit.ly/shan-chi-i-legenda-desyati-kolec

Фильм После Глава 3

Jed

https://bit.ly/posle-glava-3

После глава 3

Philipp

https://bit.ly/film-posle-glava-3-smotret-onlajn--posle-glava-3

Клятва врача

Rosemary

https://bit.ly/3A3ScTW

Дом на другой стороне

Bennett

https://bit.ly/3A9GDdy

Злое

Dario

https://bit.ly/zloe-2021-film-hd

Воспоминание

Kina

https://bit.ly/mbfilm1

Кэндимен

Alica

https://bit.ly/aaa111xz

Небесная команда

Tegan

https://bit.ly/film-2021-hd-sp

После глава 3

Therese

https://bit.ly/posle-glava-3-film

10286

Kerry

https://clck.ru/XSm2Z

Форсаж 9 смотреть онлайн в хорошем качестве

Gidget

https://bit.ly/forsazh-9-forsazh-9

Свингеры 2021

Lori

https://bit.ly/films-svingery-2021

кино тут

Margaret

https://bit.ly/3hoC8Vl

тут смотрят кино

Angelika

https://bit.ly/3hmdLI0

1031

Leonie

https://bit.ly/397ZvOd

Психолог Докучалова

Lea

http://batmanapollo.ru/

Пацанки 6 сезон

Dustin

https://bit.ly/3lwJwzj

Структурные расстановки

Miquel

https://t.me/rasstanovki_po_hellingeru

инерции

Beth

http://batmanapollo.ru/%d0%b2%d0%b2%d0%b5%d0%b4%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b2-%d0%bf%d1%81%d0%b8%d1%85%d0%be%d1%84%d0%b8%d0%b7%d0%b8%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d1%8e-%d0%bd%d0%b5%d0%b2%d1%80%d0%be%d0%b7%d0%be%d0%b2/

Ситников

Jeremy

http://batmanapollo.ru/category/sitnikov-aleksey-karmalogic-nlp-sitnikov-acmeologic-karmalogic-sitnikov-nlp/

Вытеснение

Sibyl

http://batmanapollo.ru/%d1%81%d0%bb%d0%be%d0%b2%d0%b0%d1%80%d1%8c-%d0%bf%d0%be-%d0%bf%d1%81%d0%b8%d1%85%d0%be%d0%b0%d0%bd%d0%b0%d0%bb%d0%b8%d0%b7%d1%83-%d0%bb%d0%b0%d0%bf%d0%bb%d0%b0%d0%bd%d1%88-%d0%b6%d0%b0%d0%bd/

американская история ужасов 4 серия

Antonietta

https://0rz.tw/v6rVs

Игра в кальмара 1 серия смотреть онлайн

Marina

https://bit.ly/igra-v-kalmara-1-seriya

Игра в кальмара 1 серия смотреть онлайн

Lena

https://bit.ly/igra-v-kalmara-1-seriya

k

Damaris

https://mydomdomnow.com

I campi contrassegnati con * sono obbligatori.

Condividi sui tuoi social preferiti!

Telegram Facebook Linkedin Twitter Pinterest
.