Batch file to send SMS

Home Forums iSMS Batch file to send SMS

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2642
    Adam Goldrick
    Participant

    Wondering if some one has done this.

    I have a product that monitors and when something goes wrong it runs a java script that returns two variables

    Phone number (smsReceiver) and a message (smsBody).

    I need to get these SMS’ed.

    What I can work out, is program does the folowing.


    //variables defined here

    var smsReceiver = [MobileNumber];

    var smsBody = “”The Service ” + [Title] + ” is ” + [ServiceQualityLabel] + “. Time of event: ” + [ServerTime] + “.””;

    //external batch file defined here

    //this batch script should have two parameters: a telephone number and a message body

    var batFile = “C:NotificationScript.bat”

    //execution of external bat file

    Packages.java.lang.Runtime.getRuntime().exec(batFile + ” ” + smsReceiver + ” ” + smsBody);


    What I don’t have is that bat file (NotificationScript.bat) that takes those parameters and sends it to the iSMS.

    I know I can use the http send API, I am just not a scripting person to write that code or don’t even know if I need aditional software like wget or curl (couldn’t get them to work anyway).

    Then it got me thinking..

    can it be sent directly by scripting something different then calling a bat file, like using java directly, internet search led me to this

    response.sendRedirect(“http://192.168.2.1:81/sendmsg?user=admin&passwd=admin&cat=1&to=” + smsReceiver + “&text=” + smsBody)

    I just don’t know what the “Packages.java.lang.Runtime.getRuntime().exec” or “response.sendRedirect” mean (again not a scripting person.

    Anyone?

    #3420
    Adam Goldrick
    Participant

    Answered my own question..

    /* Notification Script to send send out an SMS.

    Two variables have to be defined:

    – smsReceiver: The mobile number of the receiver, including the +61, eg: +61440123456

    – smsBody: The actual message to be sent out

    Created by: Adam Goldrick,

    Created on: 11 October 2011

    */

    //variables defined here

    var smsReceiver = [AMMobileNumber];

    var smsBody = “”The Service ” + [Title] + ” is ” + [ServiceQualityLabel] + “. Time of event: ” + [ServerTime] + “.””;

    var smsUrl = “http://192.168.2.1:81/sendmsg?user=admin&passwd=admin&cat=1&to=” + smsReceiver + “&text=” + smsBody;

    var dataToSend = “”;

    // Send the soap envelope

    xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);

    xmlhttp.open(“GET”, smsUrl, false);

    xmlhttp.setRequestHeader(“Content-Type”, “text/html; charset=utf-8”);

    xmlhttp.setRequestHeader(“Content-Length”, dataToSend.length);

    xmlhttp.send(dataToSend);

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.