Syed Jahanzaib – Personal Blog to Share Knowledge !

December 24, 2012

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

Filed under: Linux Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 2:43 PM

mobile

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 . . .)
teltonika

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)

1- detect modem

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.
2- port.
3- portname
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 🙂

wammu-on-linux
========================================================

.

Download following sms-panel-zaib.rar file from following location , and extract all files in a new folder /sms

 

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 . . .

webmin.

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 . . .

6- Create File Editor.

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.

7- Create File Editor for message.

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 . . .

8- Create File Editor for message -2

.

.

Now you will have the menu  something like below.

9- Main menu.

Now Click on the Edit Users Mobile Nos. button
& add the required mobile numbers in following manner.

10- edit mobile numbersClick 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 . . .

11- send sms

.

You can schedule various events alerts in CRON job by using pre defined message templates.

To be continued . . .

Regard’s
SYED JAHANZAIB

9 Comments »

  1. Nice Sharing 🙂

    Like

    Comment by faizan — December 24, 2012 @ 4:13 PM

  2. A very nice article……

    Like

    Comment by Adeel ahmed — December 24, 2012 @ 4:46 PM

  3. very nice

    Like

    Comment by mussawar hayat — December 24, 2012 @ 5:25 PM

  4. AOA zeeb bhai mery mikrotik server main aik problem a rhi hy k jab b koi user koi bhi site open krta hy to jo page open hota hy us pe ERROR:Gateway Timeout likha ata hy jesy agar google open krain to ERROR Gateway timeout While trying to retrieve the URL http://www.google.com/ likha ata hy ap plz bta dain yeh kis wja se ata hy or es ka kya hal hy thx

    Like

    Comment by raufaslam777 — December 26, 2012 @ 7:02 PM

  5. A-O-A sir kya mikrotik Main Client Ke access log ban sakti hay

    Like

    Comment by lksjdlaskj — January 10, 2013 @ 4:04 PM

  6. how to do this in mikrotik environment ?

    Like

    Comment by raheel — August 6, 2014 @ 11:56 AM

  7. Asalam Alaikoom!!!

    I have a sms gateway server with public IP, is it possible to use a external sms gateway for sending sms with GAMMU?

    Thanks for helping me!!!

    Like

    Comment by Hamed — September 1, 2014 @ 2:58 PM

  8. It is very effective blog for help me. Please post more related blogs. Thank you for this support.

    Visit :- sms billing

    Like

    Comment by Anderson — July 15, 2015 @ 3:15 PM


RSS feed for comments on this post. TrackBack URI

Leave a comment