/usr/share/doc/libnet-jabber-perl/examples/rpc_client.pl is in libnet-jabber-perl 2.0-6.
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 | #!/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->SetCallBacks("message" => \&InMessage,
"presence" => \&InPresence,
"iq" => \&InIQ);
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" => "RPCClient");
if ($result[0] ne "ok") {
print "ERROR: Authorization failed: $result[0] - $result[1]\n";
exit(0);
}
print "Logged in to $server:$port...\n";
my @response = $Connection->RPCCall(to=>"$username\@$server/RPCServer",
methodName=>"add",
params=>[5,4]);
if ($response[0] eq "ok") {
print "5 + 4 = ",$response[1]->[0],"\n";
}
sub Stop {
print "Exiting...\n";
$Connection->Disconnect();
exit(0);
}
|