e614cec30d83c8023064151e579bec2710302157
[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 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