[VPM] I'm a moron: posting slides and more CGI

Peter Scott peter at PSDT.com
Fri May 23 16:46:43 CDT 2003


At 11:11 AM 5/23/2003 -0700, Nathanael Kuipers wrote:
>Hello,
>
>Abram I've tried to post your tarball and pdf (as you can see by the
>error-throwing links on the vicpm site) but I'm confounded.  Neither a
>href="CORBA.pdf" nor a href="./CORBA.pdf" works because apparently the server
>looks at everything as starting with /
>
>Oh, ok, so it wants an absolute path, no problem:
>/home/groupleaders/victoria/web_docs/CORBA.pdf or
>home/groupleaders/victoria/web_docs/CORBA.pdf
>
>"Not found.  Requested URL...was not found on this server."
>
>I know that the specified directory structure is correct.

Paths != URLs.  The HREF has to be everything after the hostname part 
of the URL.

I checked it out and the server is paranoid about file modes.  That's 
something that really annoys me about Apache.  The modes were:

-rwx--x--x    1 victoria apache      62587 May 23 12:44 CORBA.pdf
-rwx--x--x    1 victoria apache     131050 May 23 12:44 CORBA.tgz

I changed them to:

-rw-r--r--    1 victoria apache      62587 May 23 12:44 CORBA.pdf
-rw-r--r--    1 victoria apache     131050 May 23 12:44 CORBA.tgz

and now the URLs http://victoria.pm.org/CORBA.pdf and 
http://victoria.pm.org/CORBA.tgz work fine.  Go ahead and change the 
links back to relative links.

>In short, I'm baffled, and I look to someone to clear this up for me.
>
>***
>
>I also have another question regarding passing parameters from one CGI to
>another.  Currently, the main cgi script accepts parameters from an 
>HTML form,
>and this works fine.  Now I want to embed links in the page served up by the
>cgi that activate other cgis.  This is what I had thought would Do What I
>Mean:
>
>...
>
>while ($hitdata = $hitsth->fetchrow_arrayref()) {
>         last if ++$count > $best;
>         print   "$count) ",join(' // ', @$hitdata)," ",
>                 $cgi->a({href=>'showquery.cgi',
>                         query=>$hitdata->[0]},'[query]')," ",
>                 $cgi->a({href=>'showhit.cgi',
>                         query=>$hitdata->[0],
>                         hit=>$hitdata->[1]},'[hit details]'),
>                 $cgi->br();
>}
>
>And here's the entire contents of query.cgi

Above refers to 'showquery.cgi', not 'query.cgi'...

>(stub form, to make sure
>everything works):
>
>#!/usr/bin/perl -wT
>
>use strict;
>use CGI;
>use CGI::Carp qw(fatalsToBrowser);
>use DBI;
>
>$| = 1;
>
>my $cgi = new CGI();
>
>print   $cgi->header(),
>         $cgi->start_html(),
>         "query param: ",$cgi->param('query'),
>         $cgi->end_html();
>
>
>__END__
>
>The result of clicking on the '[query]' link is
>
>query param:
>
>and that's it.  I know for a fact that $hitdata->[0] is defined.  What am I
>missing here?

$cgi->a({href=>'showquery.cgi',
                         query=>$hitdata->[0]},'[query]')

isn't right.

% perl -MCGI=a -le 'print a({href=>"showquery.cgi",query=>"foo"},"[query]")'
<a href="showquery.cgi" query="foo">[query]</a>

You want:

$cgi->a({href=>'showquery.cgi?query='.$hitdata->[0]},'[query]')

although if $hitdata->[0] contains any characters that aren't really 
boring then you'll need to do URI escaping on it first.



-- 
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/




More information about the Victoria-pm mailing list