Move pretty much all function down into module.
[irspy-moved-to-github.git] / irspy.pl
1 #!/usr/bin/perl -w
2
3 # $Id: irspy.pl,v 1.2 2006-05-18 21:58:43 mike Exp $
4 #
5 # Run like this:
6 #       YAZ_LOG=irspy perl -I lib irspy.pl -t "bagel.indexdata.dk/gils z3950.loc.gov:7090/Voyager" localhost:1313/IR-Explain---1
7
8 use strict;
9 use warnings;
10 use Getopt::Std;
11 use Net::Z3950::IRSpy;
12 #use ZOOM::Pod;
13
14
15 my %opts;
16 if (!getopts('t:au', \%opts) || @ARGV != 1) {
17     print STDERR qq[Usage: $0 [options] <IRSpy-database>
18         -t <t1 t2 ...>  Space-separated list of targets to check
19         -a              Check all targets registered in database
20         -u              Update information in database
21 ];
22     exit 1;
23 }
24
25 my $dbname = $ARGV[0];
26 my $targetList = $opts{t};
27 if (!defined $targetList && !$opts{a}) {
28     print STDERR "$0: neither -t nor -a specified\n";
29     exit 2;
30 }
31
32 my $spy = new Net::Z3950::IRSpy($dbname);
33 $spy->targets($targetList) if defined $targetList;
34 $spy->initialise();
35 my $query = $spy->query();
36 my $n = $spy->hitcount();
37 print "found $n records from query: $query\n";
38 $spy->check();