| 1 | #!/usr/local/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Getopt::Std qw{getopts}; | ||
| 5 | use DateTime; | ||
| 6 | use SMS::Send::Kannel::SMSbox; | ||
| 7 | |||
| 8 | my $opt = {}; | ||
| 9 | getopts("h:u:p:", $opt); #debug | ||
| 10 | my $host = $opt->{"h"}; #default undef from INI file | ||
| 11 | my $username = $opt->{"u"}; #default undef from INI file | ||
| 12 | my $password = $opt->{"p"}; #default undef from INI file | ||
| 13 | my $syntax = qq{$0 [-h host] [-u username] [-p password] phone "text"\n}; | ||
| 14 | my $to = shift or die($syntax); | ||
| 15 | my $text = shift or die($syntax); | ||
| 16 | |||
| 17 | my $service = SMS::Send::Kannel::SMSbox->new(host=>$host, username=>$username, password=>$password); | ||
| 18 | |||
| 19 | my $status = $service->send_sms( | ||
| 20 | to => $to, | ||
| 21 | text => $text, | ||
| 22 | ); | ||
| 23 | printf "%s: Phone: %s, Text: %s, Status: %s\n", DateTime->now, $to, $text, $status; | ||
| 24 | |||
| 25 | __END__ |