/usr/share/doc/libnet-jabber-perl/examples/rpc_server.pl is in libnet-jabber-perl 2.0-8.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/bin/sh
#-*-Perl-*-
exec perl -x $0 "$@"
#!perl
use Net::Jabber qw(Client);
use strict;
if ($#ARGV < 3) {
print "\nperl client.pl <server> <port> <username> <password> \n\n"
;
exit(0);
}
my $server = $ARGV[0];
my $port = $ARGV[1];
my $username = $ARGV[2];
my $password = $ARGV[3];
$SIG{HUP} = \&Stop;
$SIG{KILL} = \&Stop;
$SIG{TERM} = \&Stop;
$SIG{INT} = \&Stop;
my $Connection = new Net::Jabber::Client();
$Connection->RPCSetCallBacks(add=>\&add);
my $status = $Connection->Connect("hostname" => $server,
"port" => $port);
if (!(defined($status))) {
print "ERROR: Jabber server is down or connection was not allowed.\n";
print " ($!)\n";
exit(0);
}
my @result = $Connection->AuthSend("username" => $username,
"password" => $password,
"resource" => "RPCServer");
if ($result[0] ne "ok") {
print "ERROR: Authorization failed: $result[0] - $result[1]\n";
exit(0);
}
print "Logged in to $server:$port...\n";
while(1) {
$Connection->Process();
}
sub Stop {
print "Exiting...\n";
$Connection->Disconnect();
exit(0);
}
sub add {
my $iq = shift;
my $params = shift;
print $params->[0]," + ",$params->[1]," = ",$params->[0] + $params->[1],"\n";
return ("ok", [ $params->[0] + $params->[1] ]);
}
|