committing a simple jabber registration script
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 20 Nov 2006 14:09:12 +0000 (14:09 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 20 Nov 2006 14:09:12 +0000 (14:09 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@794 9efc2488-bf62-4759-914b-345cdb29e865

examples/register.pl [new file with mode: 0755]

diff --git a/examples/register.pl b/examples/register.pl
new file mode 100755 (executable)
index 0000000..dfde4a6
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+# ----------------------------------------------------------------------
+# Utility script for registring users on a jabber server.  
+# ----------------------------------------------------------------------
+use Net::Jabber;
+use strict;
+
+if (@ARGV < 4) {
+    print "\nperl $0 <server> <port> <username> <password> \n\n";
+    exit(0);
+}
+
+my $server = $ARGV[0];
+my $port = $ARGV[1];
+my $username = $ARGV[2];
+my $password = $ARGV[3];
+my $resource = "test_${server}_$$";
+
+my $connection = Net::Jabber::Client->new;
+
+my $status = $connection->Connect(hostname=>$server, port=>$port);
+
+my @stat = $connection->RegisterSend(
+       $server, 
+       username => $username,
+       password => $password );
+
+
+print "Register results : @stat\n";
+
+
+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=>$resource);
+
+if ($result[0] ne "ok") {
+    print "ERROR: Authorization failed: $result[0] - $result[1]\n";
+    exit(0);
+}
+
+print "Logged in OK to $server:$port\nRegistration succeeded for $username\@$server!\n";
+
+$connection->Disconnect();
+
+