Step by step solutions to IT problems

Send SMS messages from Linux

Send SMS messages using a standard dialup modem from Linux, without needing a GSM card/phone plugged into your PC. Setup automatic alerts to your cellphone using command-line sms software.

Most cellphone providers allow you to send SMS messages using an ordinary dialup modem, by dialing a special call center number. You'll need software that understands the protocols the call centers use, and many of the applications use a GUI for sending messages, which makes it hard to send automatic alerts to your cellphone.

SMS_Client is a free command line tool for Linux that can send SMS messages to a lot of different cellphone providers.

The main disadvantage of using a dialup modem, is that a common protocol for sending the messages (TAP) doesn't support setting the senders phone number - so the receiver will have to read the message to know who sent it, but this is fine for sending alerts, such as "servers down !"

Installing the Software

Download the software from the smsclient site, the latest stable version was 2.0.8y . Although the software hasn't been updated in a long time, the TAP protocol hasn't changed, so the software still works. The only change I had to make, was to the TAP phone number for my cellphone provider's call center.

Now extract the files, and configure, and compile/install the code

debian# tar -xzf sms_client-2.0.8y.tar.gz
debian# cd  sms_client-2.0.8y
debian# ./configure

Generating file 'Makefile.drivers' from file 'drivers'... Done.

Generating file 'Makefile.modemlib'... Done.

Copying 'config/Makefile.config.linux' to 'Makefile.config' Configuration complete You may wish to edit Makefile.config for site specific dependencies When you have finished, to build and install sms_client run:

make ; make install

debian# make ; make install make[1]: Entering directory `/root/sms_client-2.0.8y/src' cd common ; make make[2]: Entering directory `/root/sms_client-2.0.8y/src/common' gcc -g -I. -Wall -DLINUX -I.. -c common.c


In order to run, you will need a working modem connected to your PC, and linked via /dev/modem - so check you modem works first.

Before you run if for the first time, it's worth checking that the TAP phone number of your provider is up to date.

debian# cd /etc/sms/services
debian# less vodafone_tap
        # ------------------------------------------------------------
        # The SMSCnumber MUST be defined.
        # This is the number of your local message center.
        # ------------------------------------------------------------

SMS_centre_number = "0385499993" # UK Vodafone TAP number }

Check the numbers against the these lists of numbers. If the TAP number has changed, update the file to the new number, which in my case was a mobile number itself.

        SMS_centre_number = "07785499993"       # NEW UK Vodafone TAP number

Sending a message

We should be ready to test it now.
The syntax is sms_client provider:mobilenumber "message"

debian#  sms_client vodafone_tap:07785123456 "This is a test"
Dialing SMSC 07785499993...
WARNING: read() Timeout
Connection Established.
SMSC Acknowledgment received
Login successful
Ready to receive message
Received Message Response: Message 07785123456/2797123456 accepted by VodafoneTAP<CR>
Successful message submission
Disconnected from SMSC
vodafone_tap Service Time: 41 Seconds
[000] vodafone_tap:07785123456 "This is a test"
Total Elapsed Time: 41 Seconds
The message was received by my mobile before the dialup modem had even hung up. You can now send sms alerts from the command line, either from a custom script, or from any monitoring application (such as nagios) that supports running custom commands.
Submit to    digg    reddit    simpy