summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalmarkdown2sms16
1 files changed, 14 insertions, 2 deletions
diff --git a/localmarkdown2sms b/localmarkdown2sms
index b9de452..96ed0ac 100755
--- a/localmarkdown2sms
+++ b/localmarkdown2sms
@@ -33,6 +33,12 @@ use Proc::Fork;
#use IO::Pipe;
#Proc::Daemon::Init;
+use LWP::UserAgent;
+use URI::Escape;
+
+my $sms_url = "http://localhost:13013/cgi-bin/sendsms";
+my $sms_user = "tester";
+my $sms_pw = "foobar";
my (%file, %delay, %reply);
my ($path) = shift @ARGV;
@@ -143,8 +149,14 @@ sub sendmsg {
my ($phone, $desc, $msg) = @_;
unless ($dummy) {
- DEBUG "Exec'ing \"...sendsms $phone ...\"";
- system '/usr/share/kannel/contrib/sendsms', $phone, $msg;
+ my $ua = LWP::UserAgent->new(agent => "localmarkdown2sms");
+ $ua->timeout(10);
+ $ua->request(HTTP::Request->new('GET', $sms_url
+ . '?username=' . uri_escape($sms_user)
+ . '&password=' . uri_escape($sms_pw)
+ . '&to=' . uri_escape($phone)
+ . '&text=' . uri_escape(encode("cp1252", $msg))
+ ));
DEBUG "Done $desc";
} else {
print STDERR "\n --> $phone: $desc\n";