Scott Penrose


Scott is an expert software developer with over 30 years experience, specialising in education, automation and remote data.

Code for Aussie SMS Perl.

This code is taken directly from their PHP example. I would not have programmed it like this, but decided to make the code the same as the PHP code, with just a few Perl specific tweaks (eg. echo => print, $_POST to param). The one big change I made was to use regular expressions instead of splits to arrays, and added in more descriptive comments to explain why things are done.

use LWP::Simple;
use URI::Escape;
use CGI qw/:standard/;

# WARNING - there is no security on input here (to, from, message) - this is a
# demonstration script only.

# Your parameters
my $mobileID = "YourMobileID";
my $password = "YourPassword";

my $baseurl ="";

# Variable parameters (in this case from CGI Get or Post or Command line)
my $text = uri_escape(param('message'));
my $to = param('to');

# Send an SMS (every call must have valid ID and Password)
my $url = "$baseurl?sendsms&mobileID=$mobileID&password=$password&to=$to&text=$text&from=$mobileID&msg_type=SMS_TEXT";
my $ret = get($url);

# Check response
if ($ret =~ /MessageID:(\d+)/) {
	# Valid response, now check status of SMS message
	my $mess_id = $1;
	$url = "$baseurl?querymessage&mobileID=$mobileID&password=$password&msgid=$mess_id";
	$ret = get($url);
	if ($ret =~ /(\d)+:(.+)$/) {
		print "Message Status for $mess_id: $1 - $2\n";
	else {
		print "send message failed for $mess_id - $ret\n";
else {
	# Invalid response - assume authentication has failed
	print "Authentication failure: $ret\n";

A simple HTML form to use with it:

  <form method="get" action="/cgi-bin/aussiesms.cgi">
    To: <input name="to">
    Message: <input name="message">
    <input type="submit">