On Sat, 11 Apr 1998, Jens Schriver wrote:
> I have been using SWISH (the old version) on my site for quite a while, but a
> month ago, my isp said it used too much cpu time, and refused to let me use
> it. I think what caused the strain was more the query.pl than the actual
> searching, but I could be wrong.
>
> Has there been a more efficient version of query.pl been made (and if so,
> does it come with SWISH-E)? What about SWISH++ ... perform?
I personally have not used query.pl -- I simply wrote my own
CGI script. Not surprisingly, the current SWISH++ distribution
doesn't include any CGI script: it's left as an exercise for
the installer as it is rather trivial.
However, the next release of SWISH++ will include a toy CGI
script to interface SWISH++'s searcher to a web form. The CGI
is attached. I don't see how such a CGI could use too much CPU
time. If anybody would like the required WWW library referened
in the script, you can obtain a pre-release copy from:
ftp://wizard.arc.nasa.gov/pub/WWW.pm
- Paul J. Lucas
NASA Ames Research Center Caelum Research Corporation
Moffett Field, California San Jose, California
<pjl AT ptolemy DOT arc DOT nasa DOT gov>
----- search.cgi -----
#!/bin/perl
###############################################################################
#
# NAME
#
# search.cgi
#
# SYNOPSIS
#
# <FORM ACTION="search.cgi">
# ...
# </FORM>
#
# DESCRIPTION
#
# This is a toy example CGI script written in Perl 5 to show how to
# interface SWISH++ to a web-based search form. It uses the supplied
# www package to parse form data.
#
# SEE ALSO
#
# search(1), www(3)
#
###############################################################################
use lib ( "." );
# Put the path to where the WWW library is above.
require WWW;
$SWISH_BIN = '/home/www/swish++/bin';
# The full path to the bin directory where you installed the
# SWISH++ executables.
$INDEX_FILE = '/home/www/the.index';
# The full path to the index file to be searched through.
print "Content-Type: text/html\n\n";
# Header HTML
print <<END;
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
</HEAD>
<BODY>
<BIG><STRONG>Search Results</STRONG></BIG>
<HR>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>
END
$FORM{ search } =~ s/[^\s()*\-\w]/ /go; # zap bad chars before exposing to shell
open( SEARCH, "$SWISH_BIN/search -i $INDEX_FILE $FORM{ search } |" ) or die;
while ( <SEARCH> ) {
my( $rank, $url, $size, $title ) = split( / /, $_, 4 );
print <<END;
<TR VALIGN=top><TD ALIGN=right>$rank% </TD>
<TD><A HREF="$url">$title</A></TD>
END
}
close SEARCH;
# Footer HTML
print <<END;
</TABLE>
</BODY>
</HTML>
END
Received on Thu May 7 00:51:23 1998