Advertisement

08.01.2007 at 08:10PM PDT, ID: 22736509
[x]
Attachment Details

Incorrect URL given.

Asked by Simon336697 in CGI Scripting, Perl Programming Language

Tags: url, incorrect, wamp, wrong

Hi guys

I have a problem with the following script.

The search form is searcher.html and is:

==============================================================  searcher.html
<form action="/cgi-bin/searching.cgi" method="post">
<input type="text" name="query" size="50" />
<input type="submit" />
</form>

============================================================== searching.cgi
#!c:/perl/bin/perl.exe           
use strict;                                                      
use CGI qw(:standard);            
use File::Find;
      
my $query = param("query");

print header();
print start_html();
print "\n<p>For the query $query, these results were found:</p>\n<ol>\n";

undef $/;

find      ( sub      {
       return if ($_ =~ /^\./);                        
       return unless ($_ =~ /\.txt/i);    
       stat $File::Find::name;
       return if -d;
       return unless -r;
                                     
       open(FILE, "< $File::Find::name") or return;
      my $string = <FILE>;
      close (FILE);
                                    
      return unless ($string =~ /\Q$query\E/i);
                                    
      my $page_title = $_;            
       if ($string =~ /<title>(.*?)<\/title>/is)      {
           $page_title = $1;
       }
       print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n"; #Here we output our link.
      },
        '/wamp/'
        );
                    
        print "</ol>\n";
      print end_html();

================================================================

What happens is that the script returns the files with the search criteria in correctly. For example,
If i enter on the form 'test' for the text to find.
The problem is when I click on one of thos results, it goes to the wrong url.

If one of the results is listed as:

test.txt

And I click on this result in the browser, it takes me to:

http://localhost/wamp/www/hi/test.txt

which give me 'Web page unavailable".

The correct path should be:

http://localhost/hi/test.txt

in which case, it is displayed correctly.


------------------------------------------------------
My document root is c:\wamp\www
Search.html is in c:\wamp\www
Searching.cgi is in c:\wamp\apache2\cgi-bin

Any help appreciated.Start Free Trial
[+][-]08.01.2007 at 08:40PM PDT, ID: 19614369

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.02.2007 at 04:16AM PDT, ID: 19615821

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 04:40AM PDT, ID: 19615942

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 04:45AM PDT, ID: 19615970

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 04:58AM PDT, ID: 19616028

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 05:07AM PDT, ID: 19616071

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 05:14AM PDT, ID: 19616105

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 06:02AM PDT, ID: 19616448

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: CGI Scripting, Perl Programming Language
Tags: url, incorrect, wamp, wrong
Sign Up Now!
Solution Provided By: ahoffmann
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.02.2007 at 12:44PM PDT, ID: 19620200

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 12:57PM PDT, ID: 19620315

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.02.2007 at 11:27PM PDT, ID: 19622933

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2007 at 12:04PM PDT, ID: 19627633

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.03.2007 at 12:04PM PDT, ID: 19627636

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32