Saturday 19 January 2013

Sending Payment Reminder / Service Status SMS to Users via GAMMU using CLI/GUI

Post : Sending Payment Reminder / Service Status SMS to Users via GAMMU using CLI/GUI
URL : http://aacable.wordpress.com/2012/12/24/sending-payment-reminder-service-status-sms-to-users-via-gammu-using-cligui/
Posted : December 24, 2012 at 2:43 PM
Author : Syed Jahanzaib / Pinochio~:)
Tags : gammu sms, payment reminder via sms, send sms to users
Categories : Linux Related
http://aacable.files.wordpress.com/2012/12/mobile.gif&h=356
Following is a short guide on how you can create your own SMS panel to send SMS to users about various Events using CLI or GUI method.
For example Payment Reminder, Service Down/Up Alert, and any other message you like to convey to all users.
If you have some prior experience with the Linux/SMS tools, I am sure you will ask why to do so much manual work if you already have open source free tools like smsplay, kannel and many others available , the answer is YES the pre made tools/applications have very nice GUI and and have other functions as well, you simply have to install it by single command and that's it ready to use, but I always like to build my own solution rather then relying on the pre made applications, This way I can twist and modify the method as per my requirements. & yes its fun to play with the code and you feel much confident, happy and relaxed if you manage to create your own working solution that can fulfill your requirement.
Just FYI, DMASOFTLAB Radius Manager 4.1.x will have the function to send account expiry warning SMS before account expires.
.
Hardware Required:
# GSM Mobile / MODEM
(I used TELTONIKA GSM USB Device in this example, Picture is attached below . . .)
http://aacable.files.wordpress.com/2012/11/teltonika.jpg&h=67
Software Required:
# Ubuntu 10.x or any flavor of Linux you like to use.
# GAMMU or GNOKII (you can install gammu by apt-get install gammu )
(A very good guide for GAMMU installation & configuration is available here
http://techspalace.blogspot.com/2012/02/send-sms-using-gammu-command-line-tool.html
http://pierky.wordpress.com/2011/10/28/zabbix-send-sms-using-gammu-smsd/

Connect your GSM modem to your Linux Box via USB,
Make sure it is detected properly by Identifying it using DMESG command
dmesg | grep tty
(You may see following information if device is detected OK, As showed below)
http://aacable.files.wordpress.com/2012/12/1-detect-modem.png&h=256
As you can see that the modem have been detected as USB ACM DEVICE ttyACM0
Now run gammu config by
gammu-config
It will ask you that gammu configuration file exists, click YES to continue
Now configuration box will open, Select the PORT and EDIT & type your port name that is detected in the dmesg command.
http://aacable.files.wordpress.com/2012/12/2-port.png&h=277 .
http://aacable.files.wordpress.com/2012/12/3-portname.png&h=300
Click on OK , then SAVE and EXIT
Now identify it by using following command.
gammu --identify
(You may see following information if its connected OK , As showed below)
> root@zaib-desktop:/sms# gammu --identify
> Manufacturer         :   Teltonika
> Model                      :   unknown (TM3 EDGE)
> Firmware                :   05.41.02
> IMEI                       :   3523870xxxxxxxx
> SIM IMSI               :   410012xxxxxxx62
Test the configuration by sending SMS to your number using CLI method. Use the below command to send sms to your mobile.
> echo "Zaib Test Message" | gammu sendsms TEXT 03333021909
If you don't see any error message and receive the message to your number, then we are good to GO . . .
========================================================
TIP:
You can also use WAMMUwhich is a nice GUI frontend for GAMMU. Using it you can perform following functions easily.
Using wammu you can read/edit/delete/copy your contacts, to-do, calendar you can read/create/save/send and Backup your sms. Some type of phone supports file sending, display message including pictures and ringtones playback. Support for backup and import in various formats (vCard, vCalendar, iCalendar, gammu own backup,...) . Export messages to mail (IMAP4, maildir and mailbox storages are supported.
To install wammu, simply issue below command from GUI terminal.
apt-get install wammu
After installation completes, Goto Applications / Accessories / >Wammu
Run its configuration wizard to detect the modem and start using it :)
http://aacable.files.wordpress.com/2012/12/wammu-on-linux.png&h=265
========================================================
.
Download following sms-panel-zaib.rar (http://www.mediafire.com/?f77465ogydpe4fp) file from following location , and extract all files in a new folder /sms

http://www.mediafire.com/?f77465ogydpe4fp (http://www.mediafire.com/?f77465ogydpe4fp)
Following are the contents of /sms (after extracting)
root@zaib-desktop:~# ls /sms
start = > It executes all the scripts in order, First init , then startsms
data     => Contains Users Mobile Numbers and Names, Sample Numbers are included. Modify it as per your requirements
path => Contains all the paths for the scripts/dir
init      => This script extracts mobile nos and data from various sources and create temporarily dunp files
message => Contains Message that will be sent to users, Modify it as per your requirements
mobile.no = > Automatically created via script which contain mobile nos. only
startsm => This script actually sends sms using gammu
=============================================
Now first edit data file which contains the mobile numbers.
nano /sms/data
Type your user mobile number in the following manner
> # User's Mobile Numbers and there Names
> 03333021909 # Syed Jahanzaib-Admin No.
> 03331234567 # A-420, Lake View Cottages :d
> 03211122334 # X-20, A One Villas Bungalows :p
Now SAVE and EXIT ( By pressing CTRL+O , then ENTER, then CTRL+X )
Edit the message file, it will contain the message that will be delivered to users.
nano /sms/message
Now type your required message. For example:
> Dear User,
> Due to some scheduled maintenance work, Internet service will not be available from 3:00pm till 5:00pm on 25th December, 2012.
>
> Thank you for your co-operation & Sorry for the inconvenience.
>
> Regard's
> AA Networks (Pvt) Ltd. / zaib :)
Now SAVE and EXIT ( By pressing CTRL+O , then ENTER, then CTRL+X )
1-SEND SMS TO ALL USERS USING CLI
Now type /sms/start to execute the whole process.
It will first execute init script which will extract data from the paths / files,
Then it will start sendsms script which will actually send the sms to all the numbers fetched from init scripts (Users mobile numbers are mentioned in the data file)
2- SEND SMS TO ALL USERS USING  GUI  VIA WEBMIN
To use Customize GUI Panel, through which we can manage users mobile numbers list, and send sms to this list, You have to first install WEBMIN. which is a very nice multi purpose GUI tool to manage various Linux components
If you are using UBUNTU, you can install it via apt-get
First edit sources file, so that apt-get can fetch data from webmin directly.
nano /etc/apt/sources.list
Paste the following lines at end.
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Save & Exit.
Now execute following commands to install GPG key with which the repository is signed. Use the below command.
cd /root
wget http://www.webmin.com/jcameron-key.asc
apt-key
add jcameron-key.asc
Now you will be able to install with the commands :
apt-get update
apt-get install webmin
after successful install , you can access it using the URL  it showed you after successful message.Eample::
https://10.0.0.1:10000
[Use your root ID & Password to Login],
After successful login, you will see following screen . . .
http://aacable.files.wordpress.com/2012/12/webmin.png&h=173 .
CREATE MENU'S & LINK THEM WITH THE COMMANDS in /SMS
Now goto OTHERS / CUSTOM COMMANDS
Click on Create A New File Editor
In Description, Type any EDIT USERS MOBILE NUMBER
in File to EDIT , tpye the mobile no file name  /sms/data
Click on SAVE
As showed in the image below . . .
http://aacable.files.wordpress.com/2012/12/6-create-file-editor.png&h=188 .
Congrats, you have created a file editor which can edit the users mobile numbers,
After SAVING above file editor, you will be redirected back to main menu,
Now we will create a new file editor, which will actually send the message you type in the available box.
http://aacable.files.wordpress.com/2012/12/7-create-file-editor-for-message.png&h=81 .
In Description, Type any Send SMS to ALL
In File to EDIT , tpye the message file name  /sms/message
In Command to run after saving, type /sms/start
Click on SAVE
As showed in the image below . . .
http://aacable.files.wordpress.com/2012/12/8-create-file-editor-for-message-2.png&h=225
.
.
Now you will have the menu  something like below.
http://aacable.files.wordpress.com/2012/12/9-main-menu1.png&h=194 .
Now Click on the Edit Users Mobile Nos. button
& add the required mobile numbers in following manner.
http://aacable.files.wordpress.com/2012/12/10-edit-mobile-numbers.png&h=180 Click on SAVE to save the entries in /sms/data.
.
Now to send SMS to the list, Click on Send SMS to ALL
Type the message in the box, and click on SAVE, after saving, it will auto execute the /sms/start script which will start sending the message you just typed to the list. It may take long time to send SMS if you have large numbers of List. In my case, it took 3-4 Seconds per SMS.
As showed in the image below . . .
http://aacable.files.wordpress.com/2012/12/11-send-sms.png&h=481
.
You can schedule various events alerts in CRON job by using pre defined message templates.
To be continued . . .













































































No comments:

Post a Comment