|
Lines 1-5
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
|
|
3 |
use Modern::Perl; |
| 4 |
|
| 5 |
use Socket qw(:crlf); |
| 3 |
use IO::Socket::INET; |
6 |
use IO::Socket::INET; |
| 4 |
use Getopt::Long; |
7 |
use Getopt::Long; |
| 5 |
|
8 |
|
|
Lines 15-20
my $location_code;
Link Here
|
| 15 |
my $patron_identifier; |
18 |
my $patron_identifier; |
| 16 |
my $patron_password; |
19 |
my $patron_password; |
| 17 |
|
20 |
|
|
|
21 |
my $terminator; |
| 22 |
|
| 18 |
GetOptions( |
23 |
GetOptions( |
| 19 |
"a|address|host|hostaddress=s" => \$host, # sip server ip |
24 |
"a|address|host|hostaddress=s" => \$host, # sip server ip |
| 20 |
"p|port=s" => \$port, # sip server port |
25 |
"p|port=s" => \$port, # sip server port |
|
Lines 25-30
GetOptions(
Link Here
|
| 25 |
"patron=s" => \$patron_identifier, # patron cardnumber or login |
30 |
"patron=s" => \$patron_identifier, # patron cardnumber or login |
| 26 |
"password=s" => \$patron_password, # patron's password |
31 |
"password=s" => \$patron_password, # patron's password |
| 27 |
|
32 |
|
|
|
33 |
"t|terminator=s" => \$terminator, |
| 34 |
|
| 28 |
'h|help|?' => \$help |
35 |
'h|help|?' => \$help |
| 29 |
); |
36 |
); |
| 30 |
|
37 |
|
|
Lines 40-45
if ( $help
Link Here
|
| 40 |
exit(); |
47 |
exit(); |
| 41 |
} |
48 |
} |
| 42 |
|
49 |
|
|
|
50 |
$terminator = ( $terminator eq 'CR' ) ? $CR : $CRLF; |
| 51 |
|
| 43 |
my ( $sec, $min, $hour, $day, $month, $year ) = localtime(time); |
52 |
my ( $sec, $min, $hour, $day, $month, $year ) = localtime(time); |
| 44 |
$year += 1900; |
53 |
$year += 1900; |
| 45 |
my $transaction_date = "$year$month$day $hour$min$sec"; |
54 |
my $transaction_date = "$year$month$day $hour$min$sec"; |
|
Lines 47-61
my $transaction_date = "$year$month$day $hour$min$sec";
Link Here
|
| 47 |
my $institution_id = $location_code; |
56 |
my $institution_id = $location_code; |
| 48 |
my $terminal_password = $login_password; |
57 |
my $terminal_password = $login_password; |
| 49 |
|
58 |
|
| 50 |
$socket = IO::Socket::INET->new("$host:$port") |
59 |
my $socket = IO::Socket::INET->new("$host:$port") |
| 51 |
or die "ERROR in Socket Creation host=$host port=$port : $!\n"; |
60 |
or die "ERROR in Socket Creation host=$host port=$port : $!\n"; |
| 52 |
|
61 |
|
| 53 |
my $login_command = "9300CN$login_user_id|CO$login_password|CP$location_code|"; |
62 |
my $login_command = "9300CN$login_user_id|CO$login_password|CP$location_code|"; |
| 54 |
|
63 |
|
| 55 |
print "\nOUTBOUND: $login_command\n"; |
64 |
print "\nOUTBOUND: $login_command\n"; |
| 56 |
print $socket $login_command . "\r"; |
65 |
print $socket $login_command . $terminator; |
| 57 |
|
66 |
|
| 58 |
$data = <$socket>; |
67 |
my $data = <$socket>; |
| 59 |
|
68 |
|
| 60 |
print "\nINBOUND: $data\n"; |
69 |
print "\nINBOUND: $data\n"; |
| 61 |
|
70 |
|
|
Lines 71-77
if ( $data =~ '^941' ) { ## we are logged in
Link Here
|
| 71 |
. "|AD" . $patron_password; |
80 |
. "|AD" . $patron_password; |
| 72 |
|
81 |
|
| 73 |
print "\nOUTBOUND: $patron_status_request\n"; |
82 |
print "\nOUTBOUND: $patron_status_request\n"; |
| 74 |
print $socket $patron_status_request . "\r"; |
83 |
print $socket $patron_status_request . $terminator; |
| 75 |
|
84 |
|
| 76 |
$data = <$socket>; |
85 |
$data = <$socket>; |
| 77 |
|
86 |
|
|
Lines 80-86
if ( $data =~ '^941' ) { ## we are logged in
Link Here
|
| 80 |
## Patron Information |
89 |
## Patron Information |
| 81 |
print "\nTrying 'Patron Information'\n"; |
90 |
print "\nTrying 'Patron Information'\n"; |
| 82 |
my $summary = " "; |
91 |
my $summary = " "; |
| 83 |
my $patron_status_request = "63001" |
92 |
$patron_status_request = "63001" |
| 84 |
. $transaction_date |
93 |
. $transaction_date |
| 85 |
. $summary |
94 |
. $summary |
| 86 |
. "AO" . $institution_id |
95 |
. "AO" . $institution_id |
|
Lines 89-95
if ( $data =~ '^941' ) { ## we are logged in
Link Here
|
| 89 |
. "|AD" . $patron_password; |
98 |
. "|AD" . $patron_password; |
| 90 |
|
99 |
|
| 91 |
print "\nOUTBOUND: $patron_status_request\n"; |
100 |
print "\nOUTBOUND: $patron_status_request\n"; |
| 92 |
print $socket $patron_status_request . "\r"; |
101 |
print $socket $patron_status_request . $terminator; |
| 93 |
|
102 |
|
| 94 |
$data = <$socket>; |
103 |
$data = <$socket>; |
| 95 |
|
104 |
|
|
Lines 122-127
sip_cli_emulator.pl - SIP command line emulator
Link Here
|
| 122 |
--patron ILS patron cardnumber or username |
131 |
--patron ILS patron cardnumber or username |
| 123 |
--password ILS patron password |
132 |
--password ILS patron password |
| 124 |
|
133 |
|
|
|
134 |
-t --terminator Specifies the SIP2 message terminator, either CR, or CRLF ( defaults to CRLF ) |
| 135 |
|
| 125 |
sip_cli_emulator.pl will make requests for information about the given user from the given server via SIP2. |
136 |
sip_cli_emulator.pl will make requests for information about the given user from the given server via SIP2. |
| 126 |
|
137 |
|
| 127 |
/ |
138 |
/ |
| 128 |
- |
|
|