#!/usr/bin/perl -w # ############################################################################ # # Name: jabbernotify.pl # Author: pete@rasterweb.net # # $Id: jabbernotify.pl,v 1.3 2004/08/20 15:18:20 pete Exp pete $ # # # Description: Pipe something to this script like so: # # uptime | jabbernotify.pl # # and it should send you a message using the Jabber/XMMP protocol. # # You will need to change the server info, username, password, etc # to make it work of course... # # It does seem to have problems when sending too much data, which I # tried to fix, but finally gave up on. If you fix that, please let # me know... # ############################################################################ ############################################################################ # use use Net::Jabber qw( Client ); use strict; my $body = ""; while () { $body .= $_; } my $server = 'your.jabber.server'; my $port = 5222; my $recipient = 'some.account@jabber.server'; my $username = 'username'; my $password = '********'; my $resource = 'jabbernotify'; my $Connection = new Net::Jabber::Client(); my $status = $Connection->Connect(hostname=>$server, port=>$port); if (!(defined($status))) { print "ERROR: Jabber server is down or connection was not allowed. ($!)\n"; exit; } my @result = $Connection->AuthSend(username=>$username, password=>$password, resource=>$resource); if ($result[0] ne "ok") { print "ERROR: Authorization failed: $result[0] - $result[1]\n"; exit; } $Connection->RosterGet(); $Connection->PresenceSend(); my $message = Net::Jabber::Message->new(); $message->SetMessage( "to" => $recipient, "body" => $body ); $Connection->Send($message); sleep(1); $Connection->Disconnect(); exit; __END__