Hi Jacob,

I only use Perl for scripting, and your problem can easily be addressed with 
LWP::Simple.

Example in Perl:
-------------------
#!/usr/bin/perl

use LWP::Simple;
use URI::Escape ('uri_escape');
use Getopt::Long;

GetOptions ("n=s" => \$_nr, "t=s"=>\$_txt);
$nr = $_nr;
$txt = uri_escape($_txt);
$url = "http://192.168.9.236/source/send_sms.php?nphone=$nr&testo=$txt";;

$ret = get($url);
------------------

Calling this script with the parameters -n and -t will convert it into an URL 
fetch. The result is in $ret.

This example uses the GET method, but LWP can also use POST. Just check out the 
manual of the module.

PS: cool software that can be used to do all the SMS sending and handling, 
which support sending SMS via a simple GET method, is Kannel. I use it with 
success in my SMS system.

Grtz,

Toni Van Remortel
System Engineer @ Precision Operations N.V.
+32 3 451 92 20 - [email protected]
Satenrozen 2a, 2550 Kontich, Belgium

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jacob d'Andrade
Sent: woensdag 24 maart 2010 10:53
To: 'Opsview Users'
Subject: [opsview-users] Custom SMS Script?

Hello everyone

I'm having big trouble constructing a script that can send a sms message using 
an appliance.

I can't figure out how to construct a custom script that calls an url with the 
phone number and message as variables... I need the following command called, 
with the variables filled out... I would really appreciate if anyone could give 
me some hints on how to achieve this :-)

This code works, if I call it in a simple shell script:

---
FROMADDR=Nagios
PHONENUMBER=$1
MESSAGE_TEXT=$2
REMOTEURL=http://192.168.9.236/source/send_sms.php

curl -F "from=$FROMADDR" -F "nphone=$PHONENUMBER" -F "testo=$MESSAGE_TEXT" -F 
"send=send" -F "nc=" $REMOTEURL
---

It would be really nice, if some shell/perl guru could give me a hint or two :-)

Kind regards
Jacob

_______________________________________________
Opsview-users mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-users

Reply via email to