Forum Moderators: coopster & phranque

Message Too Old, No Replies

cgi script just shows code?

Why won't it run?

         

Nick_W

4:03 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I'm trying to run a cgi script in the root of a virtual host on RH8/Apache 2

The script wont run though, I just get the code in text on the screen?

I'm not sure even where to begin with this -- any hints much appreciated ;-)

Nick

andreasfriedrich

4:15 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to permit Apache to execute CGIs in that directory and you need to tell Apache what files constitute a CGI script.

The former is done using the

Options +ExecCGI
directive, the latter using the
AddHandler cgi-script your_cgi_extensions
directive.

There is a nice tutorial on Dynamic Content with CGI [httpd.apache.org] available at the Apache foundation website.

Andreas

Birdman

4:20 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried just renaming the file to .pl?

Nick_W

4:24 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm.. thanks andreas, I wrote a .htaccess with:

Options +ExecCGI

But the code still shows?

Nick

andreasfriedrich

4:31 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you add the AddHandler directive as well?

AddHandler cgi-script pl

if your script has the extension .pl.

Is your script executable?

Do you have AllowOverride Options privileges? This is needed to change Options from within .htaccess files.

Andreas

Nick_W

4:52 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



AddHandler cgi-script .cgi

I had to uncomment it and restart the server. I have Overide set to 'All'

Now I'm getting a 500 error :(

THanks...

Nick

andreasfriedrich

4:56 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There´s no reason to be :(. At least the server configuration is ok now and you can start debugging your script. That is :) not :(.

Andreas

Nick_W

4:57 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hehe, not my script it's a blogger thing I'm trying out:

Error message:
Premature end of script headers: gm.cgi

Shouldn't be getting that right?

Nick

andreasfriedrich

5:06 pm on Nov 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Shouldn't be getting that right?

Not unless your script looks like this:

#!/usr/bin/perl 
print "Content-type: text/html\r\n\r\n";
print "Error message:
Premature end of script headers: gm.cgi";

For some reason the script did not produce the necessary HTTP header.

Check for:
- file permissions,
- correct path to script interpreter,
- syntax error in the script.

Andreas