Skip to main content.
home | support | download

Back to List Archive

Re: Stupid novice question

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Fri Apr 02 2004 - 16:16:05 GMT
On Fri, Apr 02, 2004 at 06:59:10AM -0800, Phil Matt wrote:
> Bill Moseley wrote:
> 
> > Drop some print STDERR .... lines in John's script and watch the
> > apache error log file.
> > 
> and Peter Karman wrote:
> 
> > everyone was once a stupid novice.
> > 
> > send along your log file output from apache. that'll help.
> 
> Thanks to all for these tips. I checked the Apache logs - no errors
> reported.  As in other messages on the list (including another current
> one from Tim Barrett, the problem is that Swish-e is not working
> correctly from the CGI file, although it works just fine from the
> command line.
> 
> It is not producing errors, it just reports back no results!

Is that the exact error message?  Here's a tip in debugging:  Do things
like this:

John's script does this (in an insecure way):

open(SWISH, "$swish -w $query -m $results $search_tags -f $index|");
while (<SWISH>)
{ 

So do this in the script:

print STDERR "Running [$swish -w $query -m $results $search_tags -f $index|]\n";

open(SWISH, "$swish -w $query -m $results $search_tags -f $index|");
while (<SWISH>)
{
print STDERR "Swish output: $_";

Then copy-n-paste any messages to the list.

> I think that this means that Swish-E is indeed reading the index file
> (there is only the one I created on the server...) but somehow is not
> producing any results. There have been other threads on this list
> dealing with the same problems, but no solutions have been suggested.

Maybe, but if it works with exactly the same parameters from the command
line but not as a CGI then you HAVE to think about the difference in the
environment -- permissions and current working directory.

> 
> Does anyone know what the $params variable in John Millard's script is
> for? What parameters can be passed via this line?

You mean this?

# Optional parameters to pass to the SWISH searcher
   $params = " ";                            


I have mixed feelings about John's script.  It's fast and doesn't have
any dependencies, but that mixing of code and html is not considered
very good programming style these days.  Plus, the script is not written
in a good Perl style, either.  Not using "strict" or CGI.pm and using
global variable is considered poor practice by most in the Perl
community.  The script likely works fine, but it's not something I'd
use.  And with a quick look it seems like there's a huge security hole
in it by passing user data through the shell.

My code isn't anywhere near perfect, but you might look at search.cgi in
the distribution as an example of how to separate out the code from the
presentation.


-- 
Bill Moseley
moseley@hank.org
Received on Fri Apr 2 08:16:06 2004