#!/usr/bin/perl # # $Id: ntrs.pl,v 1.4 1995/08/22 18:16:58 alberto Exp alberto $ # # Test program for the ADS WWW library. # Reads a WAIS fielded query (such as the ones generated # by the NASA Technical Report Server) either from the command # line or from standard input, translates it into an "ADS" # abstract service WWW query, submits the query to the ADS # abstract server, and prints the results to standard output. # # Written by Alberto Accomazzi , # http://cfa-www.harvard.edu/~alberto # # $Log: ntrs.pl,v $ # Revision 1.4 1995/08/22 18:16:58 alberto # Added -encap option, and call to html_encapsulate # # Revision 1.3 1995/08/15 15:51:42 alberto # Added -db command line switch. # # Revision 1.2 1995/08/15 14:48:07 alberto # Added -debug command line switch, usage. # # Revision 1.1 1995/08/14 20:58:26 alberto # Initial revision # # if ($libloc = $ENV{'LIBWWW_PERL'}) { unshift(@INC, $libloc); } push(@INC,"/opt/local/lib/perl") if (-d "/opt/local/lib/perl"); require "www.pl"; require "wwwurl.pl"; require "wwwerror.pl"; require "adswww.pl"; while (($_ = $ARGV[0]) =~ /^\-/) { shift(@ARGV); if (/^\-debug/) { $debug = 1; $ads'debug = 1; #' } elsif (/^\-encap/) { $encap = 1; } elsif (/^\-db/) { &Usage("missing argument for \"-db\" option") unless ($opts{'db_key'} = shift(@ARGV)); } else { &Usage("unknown option $_"); } } ($waisq = join(' ',@ARGV)) =~ s/^\s+|\s+$//g; if (! $waisq) { while () { chop; $waisq .= "$_ "; } chop($waisq); } print STDERR "WAIS query: \"$waisq\"\n" if ($debug); # translate original WAIS query into an ADS fielded query %query = &ads'wais2ads($waisq); #' # add options specified on the command line foreach (keys(%opts)) { $query{$_} = $opts{$_}; } # now issue the WWW query ($result,$status) = &ads'abstract_query(%query); #' # did an error occurr? die "$0: ADS query returned the following error:\n$result\n" if ($status); # encapsulate HTML for inclusion in other documents $result = &ads'html_encapsulate($result) if ($encap); #' # print out results print $result; sub Usage { print STDERR "$0: @_\n" if (@_); print STDERR <<"EOF"; Usage: $0 [-debug] [-encap] [-db database] [query ...] If no query terms are specified on the command line, they are read from STDIN. If "-encap" is specified, the HTML code is "encapsulated" by performing the following translations: 1) HTML headers and trailers are removed 2) relative URLs are translated to absolute URLs EOF exit(1); }