Checkin and PatronInformation
[Biblio-SIP2.git] / sc-emulator.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use IO::Socket::INET;
7 use autodie;
8 use Data::Dump qw(dump);
9
10 our $user     = 'sip2-user';
11 our $password = 'sip2-paasswd';
12
13 require 'config.pl' if -e 'config.pl';
14
15 our $sock = IO::Socket::INET->new( '10.60.0.251:6001' );
16
17 sub sip2 {
18         my ( $send, $patt ) = @_;
19         warn ">>>> ", dump($send), "\n";
20         print $sock "$send\r\n";
21         $sock->flush;
22
23 #       local $/ = "\r";
24
25         my $in = <$sock>;
26         warn "<<<< ", dump($in), "\n";
27         die "expected $patt" unless $in =~ $patt;
28 }
29
30 # login
31 sip2 "9300CN$user|CO$password|" => qr/^941/;
32
33 # SC Status
34 sip2 "9900302.00" => qr/^98/;
35
36 # Checkin
37 sip2 "09N20091214    08142820091214    081428AP|AOFFZG|AB1301036581|AC|BIN|" => qr/^10/;
38
39 # Patron Information
40 sip2 "6300020091214    085452          AOFFZG|AA200903260093|AC$password|" => qr/^54/;