]> git.evergreen-ils.org Git - OpenSRF.git/blob - examples/register.pl
1. In osrf_app_session.[ch]: Create a new function
[OpenSRF.git] / examples / register.pl
1 #!/usr/bin/perl
2 # ----------------------------------------------------------------------
3 # Utility script for registring users on a jabber server.  
4 # ----------------------------------------------------------------------
5 use Net::Jabber;
6 use strict;
7
8 if (@ARGV < 4) {
9     print "\nperl $0 <server> <port> <username> <password> \n\n";
10     exit(0);
11 }
12
13 my $server = $ARGV[0];
14 my $port = $ARGV[1];
15 my $username = $ARGV[2];
16 my $password = $ARGV[3];
17 my $resource = "test_${server}_$$";
18
19 my $connection = Net::Jabber::Client->new;
20
21 my $status = $connection->Connect(hostname=>$server, port=>$port);
22
23 my @stat = $connection->RegisterSend(
24         $server, 
25         username => $username,
26         password => $password );
27
28
29 print "Register results : @stat\n";
30
31
32 if (!defined($status)) {
33     print "ERROR:  Jabber server is down or connection was not allowed.\n";
34     print "        ($!)\n";
35     exit(0);
36 }
37
38 my @result = $connection->AuthSend(
39         username=>$username, password=>$password, resource=>$resource);
40
41 if ($result[0] ne "ok") {
42     print "ERROR: Authorization failed: $result[0] - $result[1]\n";
43     exit(0);
44 }
45
46 print "Logged in OK to $server:$port\nRegistration succeeded for $username\@$server!\n";
47
48 $connection->Disconnect();
49
50