📜 ⬆️ ⬇️

Simple and convenient balance check on a Megaphone modem

Yesterday I decided to jot down something simple and convenient to check the balance on my modem from a megaphone. Already after I had put on my own, I saw similar things published yesterday on the habr ( checking the Kyivstar modem for php and checking the Kyivstar modem on python ). I offer my solution, now for a megaphone and on BASH. From the advantages I can note that it is very short, beautiful and already adapted for a megaphone.

The output of the results is made through the standard ubunt notifications. I also use gnokii to send sms (so I did it on it). So first you need to do

sudo apt-get install gnokii libnotify-bin

And create a .gnokiirc file in a user directory with the following contents:
[global]
port = /dev/ttyUSB1
model = AT-HW
initlength = default
connection = serial
use_locking = yes
serial_baudrate = 115200
handshake = hardware


Then create a sh file with the following contents:
')
#!/bin/bash
PIN=1234

notify-send "-" " ..."
echo "$PIN" | gnokii --entersecuritycode PIN
gnokii --deletesms SM 0 end
echo "0" | gnokii --sendsms 000100
sleep 2
gnokii --getsms SM 0 5 -F ~/.3g-balance.txt
sed -ie 's/^M/\n/g' ~/.3g-balance.txt
#^M , <ctrl-v><ctrl-m>
notify-send "Megafon-" "`grep '.*\.' .3g-balance.txt`"


Just correct the pin on your own. A couple of seconds after calling the script, a message appears like:
Megafon-
: 121.65.


© Web Studio iTea Lab - website development, Murmansk

It was done for myself, so no checks for incorrect PIN code, etc. not inserted

Source: https://habr.com/ru/post/98943/