Skip to main content.
home | support | download

Back to List Archive

problems indexing with autoswish

From: AusAqua <ausaqua(at)not-real.yp-connect.net>
Date: Sun Jul 22 2001 - 13:21:43 GMT
Hello,

I've recently had some very helpful answers from the group to my questions
on Swish-e and have now made good progress but am having some trouble with
Autoswish.

I've downloaded and installed swish-e-2.0.5, and autoswish 1.0 package
(which includes swish-e-1.3.3) onto a Pentium II and am trying to get
autoswish indexing and searching forms (and associated .pl files) working in
the local environment before uploading via ftp to the net.

Environment is: 

Linux Redhat 6.1 
Pentium II
Perl 5.005_03  (in usr/bin)
EGCS-2.91.66 (GCC)   (in usr/bin
swish-e is in directory /opt/swish-e-1.3.3
AutoSwish.pl is in directory
/home/httpd/cgi-bin/autoswish/swish-bin/SwishCreate
lib.pl is in directory /home/httpd/cgi-bin/autoswish/swish-bin
config.pl is in directory /home/httpd/cgi-bin/autoswish/swish-bin
nph-index.pl is in directory
/home/httpd/cgi-bin/autoswish/swish-bin/SwishCreate

Initially I installed swish-e-2.0.5 and (I believe) have correctly modified
user.config because I have no problem in creating my index via the
Command-Line system.

ie From root,  by typing "/home/httpd/cgi-bin/swish-e-2.0.5/src/swish-e -c
/home/httpd/cgi-bin/swish-e-2.0.5/conf/user.config" I get an index called
myindex1.swish-e in the directory specified by user.config.  This is as
expected from the settings I placed in user.config.

However, I have been unable to get swish-e (2.0.5) to respond when I attempt
to create that index using a (modified) form (the medium.html form from
autoswish).  There's been no response.   ie. No Index is generated and no
.conf file is produced.

Wondering if there may be some sort of compatability issue between
swish-e-2.0.5 and autoswish, I installed swish-e-1.3.3 into a different
directory and have tried getting this version of swish-e to create the index
by submission of a form but again unsucessfully.  This is despite command -
line indexing working correctly.

I have made what I think are all the required adjustments to Autoswish's
config.pl, AutoSwish.pl, lib.pl & nph-index.pl files.  However, I can't see
the problem in the files.  I've tried putting in relative references (as
you'll see from the large number of ../../ etc below in the .pl files) but
it has not solved the problem.

The address line in the form is
./../httpd/cgi-bin/autoswish/swish-bin/SwishCreate/AutoSwish.pl and this
addressing is correct; if I switch from "POST" to "GET", then I am able to
copy SwishCreate.pl into any nominated directory.

For any helpful souls out there in the swish community who may care make
suggestions, I've included the .pl files with this e-mail (although only
that portion of AutoSwish.pl which is normally changable by users).  See
below.  I'd be most grateful for any insights.

Andrew L.






AutoSwish.pl (Excerpt)- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -

#- Specify variables to secure the environment
--------------------------------#

$ENV{BASH_ENV} = ""; # for running from command line
$ENV{'SCRIPT_FILENAME'} =~ /(.*)\/.*/;
$SCRIPT_ROOT = $1;
$ENV{'PATH'} = 
"../../../../../../home/httpd/cgi-bin/autoswish/swish-bin/SwishCreate:/home/
httpd/cgi-bin/autoswish/swish-bin/SwishCreate:../../../../../../usr/bin:$SCR
IPT_ROOT";

#- Main Program 
--------------------------------------------------------------#

# untaint the user, if authentication is used
if ($ENV{REMOTE_USER}) {
$ENV{REMOTE_USER} =~ /(\w+)/;
$userid = $1;
} else {
$userid = "Unauthenticated User";
}

use CGI qw(:cgi-lib);
ReadParse;

require "$SCRIPT_ROOT/../config.pl"; # read the configuration variables
require "$SCRIPT_ROOT/../lib.pl";

# list of fields allowed
$fields = 
'(PropertyNames|WordCharacters|BeginCharacters|EndCharacters|todo|IndexComme
nts|IndexName|IndexDescription|UseStemming|IgnoreFirstChar|IgnoreLastChar|Ma
xWordLimit|MinWordLimit|IndexAdmin|BeginCharacters|EndCharacters|WordCharact
ers|IndexDir|IndexOnly|NoContents|FollowSymLinks|ReplaceRules|ReplaceRules2|
ReplaceRules3|FileRules|FileRules2|FileRules3|FileRules4|IgnoreLimit|IgnoreW
ords|todo|SimpleFlag|ConfigFile|MetaNames|RemoveFlag|RemoveRoot|ReIndex|forc
e)';




config.pl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - 


# These are the values you will want to change, according to your situation

#- Configurable Variables
----------------------------------------------------#

$SWISHDIR = "../../../../../opt/swish-e-1.3.3";
   # Location of SWISH-E executable. I have only FTP access to my server,
but I
   # can upload the compiled executable in my directory and it works
   # That does require though that you find the right executable for the
platform
   # of your ISP. 
   
$HOMEDIR = "../../../../../home/httpd/cgi-bin";
   # the HOME location of all directories and files

$CONFIGDIR = "$HOMEDIR/swish-e-2.0.5/src";
   # Location of SWISH-E configuration files. Directory needs to be writable
by 
   # the webdaemon.

$INDEXDIR = "$HOMEDIR/swish-e-2.0.5/SwishIndexes";
   # Location of SWISH-E index files. Directory needs to be writable by
   # the webdaemon.

$CGIDIR = "$HOMEDIR/autoswish/swish-bin";
   # Location of SWISH-E cgi scripts.

$CGIURL = "../../../../../home/httpd/cgi-bin/autoswish/swish-bin";
   # URL Location of SWISH-E cgi scripts.

$AUTOSWISH = "$CGIURL/SwishCreate/AutoSwish.pl";
 # the location of the AutoSwish script

$FORMDIR = "/home/Swish-E/SwishForms";
   # Location of SWISH-E form files. obsolete.

$FORMLINK = "/home/Swish-E/SwishForms";
   # Link path to the SwishForms directory. obsolete.

$WEBDIR = "../../../../../home/httpd/html";
   # Path of your system's web directory tree.

$BANNER   = "../../../../../home/httpd/html/SWISH-E/Images/powered.gif";
   # Logo to appear at the bottom of all SWISH-E pages
   
$SERVERNAME = $ENV{HTTP_HOST} || $ENV{localhost.localdomain};
   # the server url, if it's a virtual host it's HTTP_HOST, don't add the
http:// here
   # only the full domain name

$WEBMAN  = "swish-e\@$SERVERNAME";
   # E-mail address of your website manager.
           
$PERL           = '../../../../../usr/bin';
           # the location of the perl binary
           
$BODYTAG   = '<body bgcolor="#ffffff">';
           # Body tag to use in all pages
           
$TEMPLATEDIR = "../../../../../home/Swish-E/AutoSwish";
           # where are the templates for forms to fill out
           
$FULLTMPL = 'complete.shtml';
           # the template file for a complete configuration
1;






lib.pl (all code)- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -



# Subroutine to list available configuration files

sub ListConfigFiles {
local($cmd) = @_;
my $html = "<ul>";
my @configfiles = &get_config_files("$CONFIGDIR");
foreach (@configfiles) {
 $html .= "<LI><A 
HREF=\"$AUTOSWISH?todo=$cmd&ConfigFile=$_->{filename}\">$_->{name}:
$_->{description}</A>\n";
}
$html .=  "</UL>\n";
$html .=  "<b>Error: No Config files available</b>" if !@configfiles;
$html .= "\n";
}

# Subroutine for printing a generic HTML header.

sub html_header {

$document_title = $_[0];

return <<HTML_Header;
Content-type: text/html
pragma: no-cache
# Subroutine for printing a generic HTML header.

sub html_header {

$document_title = $_[0];

return <<HTML_Header;
Content-type: text/html
pragma: no-cache


<HTML>
<HEAD>
<TITLE>$document_title</TITLE>
</HEAD>
$BODYTAG
<P ALIGN=CENTER>
<a href="http://www.quipu.co.uk/SWISH-E/"><IMG
ALT="AutoSwish" BORDER=0 WIDTH=298 HEIGHT=50
SRC="/SWISH-E/Images/autoswish.gif"></A> </P>

<H2 ALIGN=CENTER>AutoSwish: Automatic Index Creation</H2>

HTML_Header
}

sub webify {
# translate some special characters in their html equivalent
$val = $_[0];
$val =~ s/"/&quot;/g;
$val =~ s/>/&gt;/g;
$val =~ s/</&lt;/g;
$val;
}

# Subroutine for printing a generic HTML footer.

sub html_footer {

return <<HTML_Footer;
<hr>
<center><a href="http://sunsite.berkeley.edu/SWISH-E/"><P ALIGN=CENTER><IMG
SRC="$BANNER" border=0></a></p>
<a href="/SWISH-E/AutoSwish/">Main index</a> | <a
href="/SWISH-E/AutoSwish/complete.shtml">Create</a> |
<a href="$AUTOSWISH?todo=listreindex&ConfigFile=.conf">Reindex</a> |
<a href="$AUTOSWISH?todo=listremove&ConfigFile=.conf">Remove</a> |
<a href="$AUTOSWISH?todo=listedit&ConfigFile=.conf">Edit</a> |


</center>
<HR>
<P ALIGN=CENTER>
Problems, Questions, Comments?<BR>
Contact your <A HREF="mailto: $WEBMAN">Web Manager</A>.
</BODY>
</HTML>
HTML_Footer

}

# Subroutine to return html - clean errors

sub return_error {

local ($status, $keyword, $message) = @_;

print &html_header("CGI Program - Unexpected Error");

print <<End_of_Error;

<center><H2>$keyword</H2>
<HR>
$message<BR>
Please contact the <A HREF="mailto:$WEBMAN">Web Manager</A> for more
information.

End_of_Error
print &html_footer;
exit(1);
}

sub web_die {
&return_error(500,"Config Error", @_);
}

sub finish {
print "Error: $_[0]\n";
exit;
}

# Subroutine to retrieve available configuration files

sub get_config_files {
local($dir) = @_[0];
opendir DIR, $dir;
my $file, @res;
while ($file = readdir(DIR)) {
next if $file !~ /\.conf$/;
my $configfile = {};
$configfile->{filename} = $file;
$configfile->{name} = &getconfigitem("IndexName","$dir/$file");
$configfile->{description} =
&getconfigitem("IndexDescription","$dir/$file"),
push @res,$configfile;
}
@res;
}

# Subroutine to read some variable from a configuration file

sub getconfigitem {
local($toget,$file) = @_;
open F, $file;
while (<F>) {
if (/$toget/i) {
 s/$toget\s+//i;
 # remove comments
 s/#.*//;
 close(F);
 chomp;
 return $_;
}
}
close(F);
return "0";
}

1;







nph-index.pl (all code)- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -

$ENV{BASH_ENV} = ""; # for running from command line
$ENV{'SCRIPT_FILENAME'} =~ /(.*)\/.*/;
$SCRIPT_ROOT = $1;
$ENV{'PATH'} = 
"../../../../../home/httpd/cgi-bin/autoswish/swish-bin:/home/httpd/cgi-bin/a
utoswish/swish-bin:/usr/local/bin:/usr/bin:$SCRIPT_ROOT";

require "$SCRIPT_ROOT/../config.pl";
require "$SCRIPT_ROOT/../lib.pl";

#- Main Program 
--------------------------------------------------------------#

$userid = $ENV{'REMOTE_USER'} || "default";
use CGI qw(:cgi-lib);
ReadParse;
$| = 1;
$nl = "<br>\n";

if ($in{'ConfigFile'} =~ /\.conf$/) {
$fileroot = $`;
$conf = "$fileroot.conf";
} else {
&return_error ("CGI ERROR",
            "Invalid ConfigFile. ");
}

$HTTP_headers =  "HTTP/1.1 200 OK\015\012";
$HTTP_headers .=  "Connection: close\015\012";
$HTTP_headers .=  "Pragma: no-cache\015\012";
print $HTTP_headers;
print &html_header("Reindexing with SWISH-E: Processing Please Wait");
open(SWISH, "$SWISHDIR/swish-e -v 3 -c $CONFIGDIR/$conf|");
while (<SWISH>) {
print "$_<br>\n";
}
print "<H2 ALIGN=CENTER>Your Files Were Succesfully Re-Indexed</H2>";
print "Command: $SWISHDIR/swish-e -c $CONFIGDIR/$conf<br>\n";
print "Index file: $CONFIGDIR/$conf<br>\n";
print "Choose another configuration file?:<BR>\n";
print &ListConfigFiles("reindex");
print &html_footer;
Received on Sun Jul 22 13:23:19 2001