Skip to main content.
home | support | download

Back to List Archive

Searching hangs thru cgi works on command line

From: Mohammed Ahmed <oklala(at)not-real.lycos.com>
Date: Sat Nov 24 2001 - 06:10:28 GMT
Hi!
I am using Swish to index a data file
using its 'prog' option.
It works great from command line.
But when deployed to web and accessed thru cgi-bin
it goes in infinite loop and gets hung
and sometimes it gives the right result ???
Well, let me explain what exactly I am doing...
A perl script generates lots of files with META tag
and some content
which is fed to Swish through -i myprog.pl option.
I also have a config file which defines the META tag
as both MetaNames and PropertyNames element.
The indexing is done. And I can search for
a word in the body or in the META tag. 
I can sort it by property.
All from command line.
But when invoked through web it gets hung.
Well, I have another indexed file similar but 
without the property/META tag, and that works fine thru web as well.
I dont know what default config is at play
when invoked thru web running on Apache.
Any help would be greatly appreciated.
Thanks,
Mohammed.
PS: I have played with a simple indexed file with property
the one Bill Mosley described in response to Julian Perry (Re: PropertyNames not working in 2.1-dev-24 ) and that seems to work 
from web too. My cgi script is a little modification of
search.cgi file.
=============================================
I am using SWISH-E 2.1-dev-24 compiled on cygwin. 
Apache HTTP Server Version 1.3
OS is Win2000.
=======================
swish-e -c c.config -i rc.pl -S prog -f rc.idx
==================
$ swish-e -w heart attack -f rc.idx -p rc
# SWISH format: 2.1-dev-24
# Search words: heart attack
# Number of hits: 1
# Search time: -0.000 seconds
# Run time: 0.010 seconds
1000 Heart attack "Heart attack" 46 "X200E"
.
=======================
But under Apache it behaves erratically...
searching for some words I get the result..
for some words which are there like "heart"
the swish-e goes in some sort of infinite loop
and never returns the call...gets hung
========================
cat c.config
PropertyNames rc
MetaNames rc
======================
cat rc.pl
#!/usr/bin/perl -w
#use strict;

sub myopen {
    open my $fh, "@_"
         or die "Can't open '@_': $!";
    return $fh;
}

sub mydoc {
my $localdoc = $_[0];
my $size = length($localdoc)+2* length("\n")+length("<META NAME='rc' CONTENT='$_[2]'>");
my $path = $_[1];
my $mtime = time;

print <<EOF;
Content-Length: $size
Last-Mtime: $mtime
Path-Name: $path

EOF
print "<META NAME=\"rc\" CONTENT=\"$_[2]\">";
print $localdoc ;
print "\n";
}

my $f = myopen("<./rcdata");
my $pdoc;
my $prc;
my $pvalue;
my $line=<$f>;
($pdoc, $prc, $pvalue) = split /\|/, $line ;
$pdoc = ""; #refresh it
do{
($doc, $rc, $value) = split /\|/, $line ;
if($prc eq $rc){
$pdoc = "$pdoc $doc"; #append it...
}else {
mydoc($pdoc, $pvalue, $prc); #changed...write it,
$pdoc = $doc;
$prc = $rc;
$pvalue = $value;
}
}while(($line=<$f>));
mydoc($pdoc, $pvalue, $prc); #for the last one
    close $f or die "Can't close la: $!";
===================================
cat search.cgi [stripped to show relevant part]
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/~!/ ~!/g;
    $FORM{$name} = $value;
}

$keystring = $FORM{'keywords'};
if ($keystring =~ /^([\w\-\. ]+)$/ ) {
    $topic = $1;
} 
else {
    &dienice("Bad keyword: `$topic'.  Please don't use commas or non-alphanumeric characters.");
}
@results = `swish-e -w $topic -f rc.idx`;

$ct = 0;
foreach $i (@results) { ............
====================================
Well, if you are laughing at my perl script...
well I am a novice here ...
Received on Sat Nov 24 06:11:01 2001