diff options
author | Jonas Smedegaard <dr@jones.dk> | 2009-08-13 19:30:15 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2009-08-13 19:30:15 +0200 |
commit | 6f907393b1887fc943e70d2f390025d6c51b4885 (patch) | |
tree | d57d5418a055301a055e55ade354a189e9765ec2 /localmarkdown2sms | |
parent | a44c8c635f07b9e77acc1fd6eddfa2cb2968e26e (diff) |
Use LWP::UserAgent (not sendsms script).
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-x | localmarkdown2sms | 16 |
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"; |