3 # This file is part of Koha.
5 # Copyright (C) 2012-2013 ByWater Solutions
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
35 my $patron_identifier;
41 "a|address|host|hostaddress=s" => \
$host, # sip server ip
42 "p|port=s" => \
$port, # sip server port
43 "su|sip_user=s" => \
$login_user_id, # sip user
44 "sp|sip_pass=s" => \
$login_password, # sip password
45 "l|location|location_code=s" => \
$location_code, # sip location code
47 "patron=s" => \
$patron_identifier, # patron cardnumber or login
48 "password=s" => \
$patron_password, # patron's password
50 "t|terminator=s" => \
$terminator,
60 || !$patron_identifier
61 || !$patron_password )
67 $terminator = ( $terminator eq 'CR' ) ?
$CR : $CRLF;
69 # Set perl to expect the same record terminator it is sending
72 my ( $sec, $min, $hour, $day, $month, $year ) = localtime(time);
74 my $transaction_date = "$year$month$day $hour$min$sec";
76 my $institution_id = $location_code;
77 my $terminal_password = $login_password;
79 my $socket = IO
::Socket
::INET
->new("$host:$port")
80 or die "ERROR in Socket Creation host=$host port=$port : $!\n";
82 my $login_command = "9300CN$login_user_id|CO$login_password|CP$location_code|";
84 print "\nOUTBOUND: $login_command\n";
85 print $socket $login_command . $terminator;
89 print "\nINBOUND: $data\n";
91 if ( $data =~ '^941' ) { ## we are logged in
93 ## Patron Status Request
94 print "\nTrying 'Patron Status Request'\n";
95 my $patron_status_request = "23001"
97 . "AO" . $institution_id
98 . "|AA" . $patron_identifier
99 . "|AC" . $terminal_password
100 . "|AD" . $patron_password;
102 print "\nOUTBOUND: $patron_status_request\n";
103 print $socket $patron_status_request . $terminator;
107 print "\nINBOUND: $data\n";
109 ## Patron Information
110 print "\nTrying 'Patron Information'\n";
112 $patron_status_request = "63001"
115 . "AO" . $institution_id
116 . "|AA" . $patron_identifier
117 . "|AC" . $terminal_password
118 . "|AD" . $patron_password;
120 print "\nOUTBOUND: $patron_status_request\n";
121 print $socket $patron_status_request . $terminator;
125 print "\nINBOUND: $data\n";
129 print "\nLogin Failed!\n";
134 q
/sip_cli_emulator
.pl
- SIP command line emulator
136 Test a SIP2 service by sending patron status
and patron
137 information requests
.
140 sip_cli_emulator
.pl
[OPTIONS
]
143 --help display help message
145 -a
--address SIP server ip address
or host name
146 -p
--port SIP server port
148 -su
--sip_user SIP server login username
149 -sp
--sip_pass SIP server login password
151 -l
--location SIP location code
153 --patron ILS patron cardnumber
or username
154 --password ILS patron password
156 -t
--terminator SIP2 message terminator
, either CR
, or CRLF