Re: Command line to test sms delivery
Zeno Davatz <[email protected]>
| Newsgroups | gmane.network.netsaint.user |
|---|---|
| Message-ID | <B9F03C2D.416E%[email protected]> |
On 7.11.2002 15:02 Uhr, "Bishop, Dean" <[email protected]> wrote: > snd the script #!/usr/bin/perl # # This example demonstrates how to submit a SMS message to the # NovelSoft SMSC from a CGI Perl script # use IO::Socket; #################################################### # PLEASE READ THE SPECIFICATIONS AT # # http://www.novelsoft.ch/sms-software/httpsms.pdf # #################################################### # REPLACE THIS BY A VALID SMS USERNAME AND PASSWORD # $USERNAME = ""; $PASSWORD = ""; #$TEST = 1; # Delete this line after debugging # Get the message and the recipient number # (We assume that the message is passed to the script in M, # and the number list in N) # The numbers are in the form "CountrycodeAreacodeHandset", # e.g. "41791234567,44324445664" etc. # $numbers = $ARGV[0]; $message = $ARGV[1]; # Translate reserved characters in the message string to hex # to avoid confusing the web server # $message =~ s{([&\+%# =])}{hx($1)}ge; # Now we can establish the connection to one of the SMS access servers # This assumes we can connect directly, not via a proxy server! # $sock = connectServer("clients.sms-wap.com", 80) || connectServer("clients2.sms-wap.com", 80) || connectServer("clients3.sms-wap.com", 80); if (defined($sock)) { # Connection ok # $sock->autoflush(1); # Construct the query string to send and determine its length # UID, PW = username and password (required) # N = list of comma-separated recipient numbers (required) # M = text message (required) # $str = "UID=$USERNAME&PW=$PASSWORD&TEST=$TEST&N=$numbers&M=$message"; $len = length($str); # Send request # $sock->print("POST /cgi/csend.cgi HTTP/1.0\n"); $sock->print("Host: clients.sms-wap.com\n"); $sock->print("Content-type: application/x-www-form-urlencoded\n"); $sock->print("Content-length: $len\n\n"); $sock->print("$str\n"); # Get response (2-digit numeric code) # 01 = OK, message scheduled for delivery # 97 = syntax error or missing parameters # 98 = insufficient account balance # 99 = other error # while ($_ = <$sock>) { if (/^(\d+)/) { $result = $1; last; } } $sock->close; print("Server-Response: $result\n") } else { print("Connection to all Servers failed!\n") } exit 0; ### THE END ### ######### # This subroutine tries to connect to a given SMS server. # sub connectServer { my($srv, $port) = @_; return IO::Socket::INET->new( Proto => "tcp", PeerAddr => $srv, PeerPort => $port ); } ######### # This subroutine takes a character and returns its hex ASCII code, # prefixed with % (e.g. "A" becomes "%41") # sub hx { my($char) = @_; return sprintf "%%%X", ord($char); } > -----Original Message----- > From: Zeno Davatz [mailto:[email protected]] > Sent: Thursday, November 07, 2002 8:34 AM > To: [email protected] > Subject: Re: [netsaint] Command line to test sms delivery > > > Good afternoon > > On 7.11.2002 14:28 Uhr, "Bishop, Dean" <[email protected]> wrote: >> well you could use check_nt to see if the windows service is running. >> >> is this what you mean? > No not really. I got a script that I used before and that worked actually > fine. Now I installed netsaint on a new Debian-Server and would like to know > if it still sends me an sms. > > I know I could do it from the webinterface but I would like to test it from > the command line. > > Zeno > >> -----Original Message----- >> From: Zeno Davatz [mailto:[email protected]] >> Sent: Thursday, November 07, 2002 8:10 AM >> To: [email protected] >> Subject: [netsaint] Command line to test sms delivery >> >> >> Hi >> >> Is there a command line argument to test if my sms service is working >> correct? >> >> My sms-script is in /usr/local/netsaint/libexec/alert_sms.pl >> >> Thanks for any help and hints. >> >> Zeno >> >> >> >> ------------------------------------------------------- >> This sf.net email is sponsored by: See the NEW Palm >> Tungsten T handheld. Power & Color in a compact size! >> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en >> _______________________________________________ >> Netsaint-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/netsaint-users >> ------------------------------------------------------- This sf.net email is sponsored by: See the NEW Palm Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en