Sending WAP Push and Binary SMS from the Command Line

Posted by on Jan 12, 2009 in Support Blog

Topic Keywords: ,

In past postings, we’ve provided a variety of command line script examples that make it easy to interface with NowSMS from a command line interface.

The original command line interface, designed to send standard text messages can be found at the following link: http://www.nowsms.com/sending-sms-from-command-line

A script to enable sending MMS messages from a command line interface was published at the following link: http://www.nowsms.com/sending-mms-from-the-command-line

And a script to enable sending OMA Client Provisioning Content (XML Settings) was published at the following link: http://www.nowsms.com/send-oma-client-provisioning-ota-xml-settings-from-the-command-line

All of these scripts can be executed from a standard command line interface, making it easy to interface with NowSMS from a variety of different environments.

However, suppose you want to send WAP push messages or other types of binary SMS messages from a command line interface? It is relatively easy to adapt the other examples for this purpose, but we decided to provide an example to make it even easier.

Download the Windows script file sms2.js from http://www.nowsms.com/download/sms2.js.txt. (Right click and save this file as sms2.js.)

Assuming that the script file is saved as a file named sms2.js, you would issue the following command:

cscript sms2.js PhoneNumber1[,PhoneNumber2,…] NowSMSURLParameter1=Value1 [NowSMSURLParameter2=Value2] [NowSMSURLParameterN=ValueN]

(cscript.exe is the Windows Script Host, which is a component of Windows which should be located in the \Windows\System32 directory.)

NowSMSURLParameter1=Value1 can be any of the URL parameters documented for NowSMS at http://www.nowsms.com/doc/submitting-sms-messages/url-parameters.

However, one difference from the URL parameter interface is that this script will perform any necessary URL escaping to simplify the user interface to the script.

Multiple URL parameters can be specified via this command line interface.

For example, to send a WAP push message, the following command could be used:

cscript sms2.js +44777777777 WAPURL=http://www.nowsms.com “Text=This is a test push”

In this example, because the “Text=” parameter includes spaces, we put quotes around the paramter and value, so that it is recognised as a single parameter value combination.

A simpler example would be sending a message to turn on the voice message waiting indicator (MWI):

cscript sms2.js +44777777777 VoiceMail=On

Or, if you have a pre-constructed binary message, you can directly specify the UDH and Data parameters, such as in the following example:

cscript sms2.js +44777777777 Binary=1 UDH=080D0200040B020007 Data=20 DCS=8

A more complex example would be sending an EMS message. NowSMS defines simple mark-up tags for inserting attributes into an EMS text message. For example, “This is a <b>test</b>!” encodes the text with “test” highlighted as bold on supported EMS compatible phones.

Unfortunately, the “<” and “>” characters are used for input/output redirection from the Windows command line. Therefore to include those characters in a command line string, it is necessary to preface the character with the escape character “^”.

To send this EMS message, the following command line would be used:

cscript sms2.js +44777777777 “EMSText=This is a ^<b^>test^</b^>!”

For comments and further discussion, please click here to visit the NowSMS Technical Forums (Discussion Board)...