SMS Command Line Interface?

SMS Command Line Interface? SearchSearch
Author Message
Alex
Posted on Thursday, June 12, 2003 - 08:09 pm:   

Dear Sir,

Does Now SMS support to send SMS via command line?

My network management system could send SNMP trap and executed script.

How could I trigger the alert to be sent by Now SMS?

Best regards,

Alex
Bryce Norwood - NowSMS Support
Posted on Thursday, June 12, 2003 - 08:16 pm:   

Hi Alex,

We have an HTTP command interface in NowSMS, where you can send a message by issuing an HTTP GET request to the gateway. (At a very simple level, this is a matter of connecting to the configured port on the gateway and issuing a command "GET /?PhoneNumber=xxxx&Text=text+of+message HTTP/1.0\r\n\r\n". Note that the text needs to be URL escaped according to HTTP specifications.)

If you're in the Windows environment, and you need to send a message through a command line interface, you could use simple scripting to create a script that runs from a command line interface.

For example, here's a real simple script.

Save the following with a file name of "sms.js", and modify the last line of the script to reference your NowSMS server, the phone number you want to send to, and the text of the message (with a little more work, you could turn those fields into variables for the script).

----- begin sms.js -----
function HTTPGET(strURL)
{
var strResult;

try
{
// Create the WinHTTPRequest ActiveX Object.
var WinHttpReq = new ActiveXObject("Msxml2.XMLHTTP" /* or "WinHttp.WinHttpRequest.5"*/);

// Create an HTTP request.
var temp = WinHttpReq.Open("GET", strURL, false);

// Send the HTTP request.
WinHttpReq.Send();

// Retrieve the response text.
strResult = WinHttpReq.ResponseText;
}
catch (objError)
{
strResult = objError + "\n"
strResult += "WinHTTP returned error: " +
(objError.number & 0xFFFF).toString() + "\n\n";
strResult += objError.description;
}

// Return the response text.
return strResult;
}

WScript.Echo(HTTPGET("http://mms.host.ip:port/?PhoneNumber=phonenumber&User=user name&password=password&text=SNMP+Trap+has+occurred"));

----- end sms.js -----

Then, you can run "cscript sms.js", which loads the Windows script host (cscript.exe) to process this script.

Hope that helps!

-bn