Home   >>   Kannel   >>   Bash Script To Send Text Message Using Kannel
Bash Script To Send Text Message Using Kannel PDF Print E-mail
( 0 Votes )
How To - Kannel
Written by Christian Foronda   
Tuesday, 07 September 2010 18:30

Tested to work on CentOS

This assume that you already have a working Kannel installed.

Prerequisites :

  • Kannel
  • Perl
  • Perl URI::Escape module
  • Wget
  •  

    	$ vi sendsms
    
    	#!/bin/bash
    
    	TO=$1
    	if [ "$TO" == "" ]; then 
    	  echo 'Usage: sendsms MSISDN "message"'
    	  exit
    	fi
    
    	shift
    	MSG=$@
    	if [ "$MSG" == "" ]; then 
    	  echo 'Usage: sendsms MSISDN "message"'
    	  exit
    	fi
    
    	URL="http://127.0.0.1:13003/cgi-bin/sendsms?username=MYUSER&password=MYPASSWORD&from=NUMBERMASK&to=$TO&text=$(echo -n $MSG | perl -MURI::Escape -lne 'print uri_escape($_)')"
    	wget $URL -O /dev/null -o /dev/null 
    
    	$ chmod +x sendsms
    

    Sample usage:

    	$ sendsms 12345678900 "This is a test"
    

    For sending to multiple recipients:

    	$ sendsms 12345678900+00987654321 "This is a test"
    



    blog comments powered by Disqus
    Last Updated on Tuesday, 07 September 2010 21:57