Bug 12495 - Include streetnumber in hold alert address
[koha_fer] / misc / sip_cli_emulator.pl
index 708b1bb..b6d7880 100755 (executable)
@@ -1,5 +1,22 @@
 #!/usr/bin/perl
 
+# This file is part of Koha.
+#
+# Copyright (C) 2012-2013 ByWater Solutions
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
 use Modern::Perl;
 
 use Socket qw(:crlf);
@@ -18,7 +35,7 @@ my $location_code;
 my $patron_identifier;
 my $patron_password;
 
-my $terminator;
+my $terminator = q{};
 
 GetOptions(
     "a|address|host|hostaddress=s" => \$host,              # sip server ip
@@ -43,12 +60,15 @@ if (   $help
     || !$patron_identifier
     || !$patron_password )
 {
-    print help();
+    print &help();
     exit();
 }
 
 $terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF;
 
+# Set perl to expect the same record terminator it is sending
+$/ = $terminator;
+
 my ( $sec, $min, $hour, $day, $month, $year ) = localtime(time);
 $year += 1900;
 my $transaction_date = "$year$month$day    $hour$min$sec";
@@ -109,31 +129,32 @@ else {
     print "\nLogin Failed!\n";
 }
 
-sub help() {
+sub help {
     print
-q/
-sip_cli_emulator.pl - SIP command line emulator
-
-  Usage:
-    sip_cli_emulator.pl --address localhost -port 6001 --sip_user myuser --sip_pass mypass --location MYLOCATION --patron 70000003 --password Patr0nP@ssword
+q/sip_cli_emulator.pl - SIP command line emulator
 
-  Options:
-    --help          brief help message
+Test a SIP2 service by sending patron status and patron
+information requests.
 
-    -a --address    SIP server ip address or host name
-    -p --port       SIP server port
+Usage:
+  sip_cli_emulator.pl [OPTIONS]
 
-    -su --sip_user  SIP server login username
-    -sp --sip_pass  SIP server login password
+Options:
+  --help           display help message
 
-    -l --location   SIP location code
+  -a --address     SIP server ip address or host name
+  -p --port        SIP server port
 
-    --patron        ILS patron cardnumber or username
-    --password      ILS patron password
+  -su --sip_user   SIP server login username
+  -sp --sip_pass   SIP server login password
 
-    -t --terminator    Specifies the SIP2 message terminator, either CR, or CRLF ( defaults to CRLF )
+  -l --location    SIP location code
+  --patron         ILS patron cardnumber or username
+  --password       ILS patron password
 
-sip_cli_emulator.pl will make requests for information about the given user from the given server via SIP2.
+  -t --terminator  SIP2 message terminator, either CR, or CRLF
+                   (defaults to CRLF)
 
 /