1751907 Members
4626 Online
108783 Solutions
New Discussion юеВ

Re: Perl CGI question

 
SOLVED
Go to solution
Jason Berendsen
Regular Advisor

Perl CGI question

I have recently installed Apache web server on one of our A class test boxes. I am trying to write a simplistic Perl CGI script that will have a set of HTML links on a main page. I have the following line in the script to achieve the link:

Rack Layout


Everytime I attempt to use this link within Netscape I get the following error in the Apache error_log:
attempt to invoke directory as script: /
usr/local/apache/cgi-bin

Why isn't it using the full http all the way out to the image.cgi?

Thanks,
Jason
8 REPLIES 8
harry d brown jr
Honored Contributor

Re: Perl CGI question


What is the ServerRoot set to in ./conf/httpd.conf?

live free or die
harry
Live Free or Die
Jason Berendsen
Regular Advisor

Re: Perl CGI question

Harry,

ServerRoot is set to /usr/local/apache

I have tried the following line in the script to no avail:

harry d brown jr
Honored Contributor

Re: Perl CGI question

What about your ScriptAlias section?

live free or die
harry
Live Free or Die
Jason Berendsen
Regular Advisor

Re: Perl CGI question

The ScriptAlias line is set to: ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
harry d brown jr
Honored Contributor
Solution

Re: Perl CGI question

Try this SIMPLE test:

CREATE a simple CGI called dummy.cgi in the /opt/apache/cgi-bin directory:

*** NOTE the CONTENT TYPE should say text/html


#!/usr/local/bin/perl
##
## Make sure you get the right PERL directory
##

print "Content-type: text/html\n\n";
print "TEST a CGI\n\n";


CHECK the permissions:
# ls -l /opt/apache/cgi-bin/dummy.cgi
-r-xr-xr-x 1 root sys 198 Jul 29 13:27 /opt/apache/cgi-bin/dummy.cgi
#


live free or die
harry
Live Free or Die
Jason Berendsen
Regular Advisor

Re: Perl CGI question

Harry,

That worked without a problem. I substituted the test-cgi with my image.cgi and that also worked. As of yet I am not sure what exactly was wrong with my syntax, but this gives me something to compare with.

Thanks,

Jason
harry d brown jr
Honored Contributor

Re: Perl CGI question


Probably:

print "Content-type: text/html\n\n";


The Content TYPE is important and the TWO carriage returns (/n/n) are the MOST important thing.

live free or die
harry
Live Free or Die
Ralph Grothe
Honored Contributor

Re: Perl CGI question

Hi Jason,

if it wasn't only for testing your webserver's cgi capability, and you are interested in doing some more CGI stuff with Perl, I can strongly recommend to use the fine CGI.pm module by Lincoln Stein.
CGI.pm is standard in every current Perl installation.
At the shell type "perldoc CGI".

Why would you want to use this module then?
Because there is so much rotten Perl CGI code floating around that usage of these scripts (like self written URL decoding parsers) can open security holes.
Especially when fiddling with parameters and user input.
CGI.pm has a fine param() method that takes the burden from you.
Please, also find out about Perl's taint checking (perldoc perlsec).
On a production webserver should no script be running without the -T flag.

There was in fact so much dubious Perl CGI code (like those from Matt Wright) that proficient Perl developers saught for a replacement and came up with this:

http://nms-cgi.sourceforge.net/

use it.
Madness, thy name is system administration