Hi everyone,
I'm currently using Matt's search.pl. It works fine with my own website. But now I would like to use it on a SQL window NT server. Unfortunatelly it doesn't work. It says my $basedir path is NOT correct. I'm following the guidelines from the scripts and I had no problem with it on my own website. If my files are stored in a 'cgi-bin' and the serverhost name is '10.10.13.103:101'. Is it correct to put $basedir = '/10.10.13.103:101/cgi-bin/'; ?? If not, what is the correct method? Can anyone please help me?
THANK YOU VERY MUCH
The script is listed below.
Rowina
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
# base directory where user would like to search from
$basedir = /10.10.13.103:101/cgi-bin/ONE';
$baseurl = '@files = ('*.html');
$title = "DatabaseSearch ONE";
$title_url = '$search_url = '&parse_form;
&get_files;
&search;
# Print Results of Search
&return_html;
sub parse_form
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@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;
$FORM{$name} = $value;
}
}
sub get_files
{
chdir($basedir);
foreach $file (@files)
{
$ls = `ls $file`;
@ls = split(/\s+/,$ls);
foreach $temp_file (@ls)
{
if (-d $file)
{
$filename = "$file$temp_file";
if (-T $filename)
{
push(@FILES,$filename);
}
}
elsif (-T $temp_file)
{
push(@FILES,$temp_file);
}
}
}
}
sub search
{
@terms = split(/\s+/, $FORM{'terms'});
foreach $FILE (@FILES)
{
open(FILE,"$FILE"
@LINES = <FILE>;
close(FILE);
$string = join(' ',@LINES);
$string =~ s/\n//g;
if ($FORM{'boolean'} eq 'AND')
{
foreach $term (@terms)
{
if ($FORM{'case'} eq 'Insensitive')
{
if (!($string =~ /$term/i))
{
$include{$FILE} = 'no';
last;
}
else
{
$include{$FILE} = 'yes';
}
}
elsif ($FORM{'case'} eq 'Sensitive')
{
if (!($string =~ /$term/))
{
$include{$FILE} = 'no';
last;
}
else
{
$include{$FILE} = 'yes';
}
}
}
}
elsif ($FORM{'boolean'} eq 'OR')
{
foreach $term (@terms)
{
if ($FORM{'case'} eq 'Insensitive')
{
if ($string =~ /$term/i)
{
$include{$FILE} = 'yes';
last;
}
else
{
$include{$FILE} = 'no';
}
}
elsif ($FORM{'case'} eq 'Sensitive')
{
if ($string =~ /$term/)
{
$include{$FILE} = 'yes';
last;
}
else
{
$include{$FILE} = 'no';
}
}
}
}
if ($string =~ /<title>(.*)<\/title>/i)
{
$titles{$FILE} = "$1";
}
else
{
$titles{$FILE} = "$FILE";
}
}
}
# return the output page
sub return_html
{
print "Content-type: text/html\n\n";
print "<html>\n <head>\n <title>Search Results</title>\n </head>\n";
print "<body>\n <center>\n <h1>Results of Search in $title</h1>\n </center>\n";
print "Search Results:<p>
<hr size=7 width=75%><p>\n";
print "<ul>\n";
foreach $key (keys %include)
{
if ($include{$key} eq 'yes')
{
print "<li><a href=\"$baseurl$key\">$titles{$key}</a>\n";
}
}
print "</ul>\n";
print "<hr size=7 width=75%>\n";
print "Search Information:<p>\n";
print "<ul>\n";
print "<li><b>Terms:</b> ";
$i = 0;
foreach $term (@terms)
{
print "$term";
$i++;
if (!($i == @terms))
{
print ", ";
}
}
print "\n";
print "</ul><br><hr size=7 width=75%><P>\n";
print "<li><a href=\"$title_url\">Back to User Login</a>\n";
print "</ul>\n";
print "</body>\n</html>\n";
}
I'm currently using Matt's search.pl. It works fine with my own website. But now I would like to use it on a SQL window NT server. Unfortunatelly it doesn't work. It says my $basedir path is NOT correct. I'm following the guidelines from the scripts and I had no problem with it on my own website. If my files are stored in a 'cgi-bin' and the serverhost name is '10.10.13.103:101'. Is it correct to put $basedir = '/10.10.13.103:101/cgi-bin/'; ?? If not, what is the correct method? Can anyone please help me?
THANK YOU VERY MUCH
The script is listed below.
Rowina
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
# base directory where user would like to search from
$basedir = /10.10.13.103:101/cgi-bin/ONE';
$baseurl = '@files = ('*.html');
$title = "DatabaseSearch ONE";
$title_url = '$search_url = '&parse_form;
&get_files;
&search;
# Print Results of Search
&return_html;
sub parse_form
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@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;
$FORM{$name} = $value;
}
}
sub get_files
{
chdir($basedir);
foreach $file (@files)
{
$ls = `ls $file`;
@ls = split(/\s+/,$ls);
foreach $temp_file (@ls)
{
if (-d $file)
{
$filename = "$file$temp_file";
if (-T $filename)
{
push(@FILES,$filename);
}
}
elsif (-T $temp_file)
{
push(@FILES,$temp_file);
}
}
}
}
sub search
{
@terms = split(/\s+/, $FORM{'terms'});
foreach $FILE (@FILES)
{
open(FILE,"$FILE"
@LINES = <FILE>;
close(FILE);
$string = join(' ',@LINES);
$string =~ s/\n//g;
if ($FORM{'boolean'} eq 'AND')
{
foreach $term (@terms)
{
if ($FORM{'case'} eq 'Insensitive')
{
if (!($string =~ /$term/i))
{
$include{$FILE} = 'no';
last;
}
else
{
$include{$FILE} = 'yes';
}
}
elsif ($FORM{'case'} eq 'Sensitive')
{
if (!($string =~ /$term/))
{
$include{$FILE} = 'no';
last;
}
else
{
$include{$FILE} = 'yes';
}
}
}
}
elsif ($FORM{'boolean'} eq 'OR')
{
foreach $term (@terms)
{
if ($FORM{'case'} eq 'Insensitive')
{
if ($string =~ /$term/i)
{
$include{$FILE} = 'yes';
last;
}
else
{
$include{$FILE} = 'no';
}
}
elsif ($FORM{'case'} eq 'Sensitive')
{
if ($string =~ /$term/)
{
$include{$FILE} = 'yes';
last;
}
else
{
$include{$FILE} = 'no';
}
}
}
}
if ($string =~ /<title>(.*)<\/title>/i)
{
$titles{$FILE} = "$1";
}
else
{
$titles{$FILE} = "$FILE";
}
}
}
# return the output page
sub return_html
{
print "Content-type: text/html\n\n";
print "<html>\n <head>\n <title>Search Results</title>\n </head>\n";
print "<body>\n <center>\n <h1>Results of Search in $title</h1>\n </center>\n";
print "Search Results:<p>
<hr size=7 width=75%><p>\n";
print "<ul>\n";
foreach $key (keys %include)
{
if ($include{$key} eq 'yes')
{
print "<li><a href=\"$baseurl$key\">$titles{$key}</a>\n";
}
}
print "</ul>\n";
print "<hr size=7 width=75%>\n";
print "Search Information:<p>\n";
print "<ul>\n";
print "<li><b>Terms:</b> ";
$i = 0;
foreach $term (@terms)
{
print "$term";
$i++;
if (!($i == @terms))
{
print ", ";
}
}
print "\n";
print "</ul><br><hr size=7 width=75%><P>\n";
print "<li><a href=\"$title_url\">Back to User Login</a>\n";
print "</ul>\n";
print "</body>\n</html>\n";
}