From 6f907393b1887fc943e70d2f390025d6c51b4885 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 13 Aug 2009 19:30:15 +0200 Subject: Use LWP::UserAgent (not sendsms script). --- localmarkdown2sms | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'localmarkdown2sms') 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"; -- cgit v1.2.3