From bb2874c30445391fe1b048f9f107fc01b2efb8f0 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 8 Jul 2013 09:21:25 -0400 Subject: [PATCH] Bug 9288: (follow-up) add --terminator option; use Modern::Perl Signed-off-by: Katrin Fischer Signed-off-by: Galen Charlton (cherry picked from commit 0f521663cf73b1c1122712d08094c65f1d59df6a) Signed-off-by: Fridolin Somers --- misc/sip_cli_emulator.pl | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/misc/sip_cli_emulator.pl b/misc/sip_cli_emulator.pl index a379da2aff..708b1bb558 100755 --- a/misc/sip_cli_emulator.pl +++ b/misc/sip_cli_emulator.pl @@ -1,5 +1,8 @@ #!/usr/bin/perl +use Modern::Perl; + +use Socket qw(:crlf); use IO::Socket::INET; use Getopt::Long; @@ -15,6 +18,8 @@ my $location_code; my $patron_identifier; my $patron_password; +my $terminator; + GetOptions( "a|address|host|hostaddress=s" => \$host, # sip server ip "p|port=s" => \$port, # sip server port @@ -25,6 +30,8 @@ GetOptions( "patron=s" => \$patron_identifier, # patron cardnumber or login "password=s" => \$patron_password, # patron's password + "t|terminator=s" => \$terminator, + 'h|help|?' => \$help ); @@ -40,6 +47,8 @@ if ( $help exit(); } +$terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF; + my ( $sec, $min, $hour, $day, $month, $year ) = localtime(time); $year += 1900; my $transaction_date = "$year$month$day $hour$min$sec"; @@ -47,15 +56,15 @@ my $transaction_date = "$year$month$day $hour$min$sec"; my $institution_id = $location_code; my $terminal_password = $login_password; -$socket = IO::Socket::INET->new("$host:$port") +my $socket = IO::Socket::INET->new("$host:$port") or die "ERROR in Socket Creation host=$host port=$port : $!\n"; my $login_command = "9300CN$login_user_id|CO$login_password|CP$location_code|"; print "\nOUTBOUND: $login_command\n"; -print $socket $login_command . "\r"; +print $socket $login_command . $terminator; -$data = <$socket>; +my $data = <$socket>; print "\nINBOUND: $data\n"; @@ -71,7 +80,7 @@ if ( $data =~ '^941' ) { ## we are logged in . "|AD" . $patron_password; print "\nOUTBOUND: $patron_status_request\n"; - print $socket $patron_status_request . "\r"; + print $socket $patron_status_request . $terminator; $data = <$socket>; @@ -80,7 +89,7 @@ if ( $data =~ '^941' ) { ## we are logged in ## Patron Information print "\nTrying 'Patron Information'\n"; my $summary = " "; - my $patron_status_request = "63001" + $patron_status_request = "63001" . $transaction_date . $summary . "AO" . $institution_id @@ -89,7 +98,7 @@ if ( $data =~ '^941' ) { ## we are logged in . "|AD" . $patron_password; print "\nOUTBOUND: $patron_status_request\n"; - print $socket $patron_status_request . "\r"; + print $socket $patron_status_request . $terminator; $data = <$socket>; @@ -122,6 +131,8 @@ sip_cli_emulator.pl - SIP command line emulator --patron ILS patron cardnumber or username --password ILS patron password + -t --terminator Specifies the SIP2 message terminator, either CR, or CRLF ( defaults to CRLF ) + sip_cli_emulator.pl will make requests for information about the given user from the given server via SIP2. / -- 2.39.5