Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unable to run any cgi script...

Status
Not open for further replies.

secretsquirrel

Programmer
Mar 22, 2001
202
GB
hi guys,

i'm a cgi newbie, and i'm slowly losing my patience...

i've not been having much luck running some scripts i've downloaded, so i've decided to go back to basics and try and run the script under the 'simplest cgi' section of faq452-653, but all i get is a '500 internal server error' in my browser and a 'premature end of script headers' error in my log.

i've made sure of the following:
- my file is being uploaded in ascii format
- the permissions are set to 755 (but i've tried 777 as well with the same result)
- my path to perl is correct
- i am able to run cgi scripts on my server
- i have put the file in the cgi-bin folder

thanks for any help,

ss...
 
Did you try changing the [tt]\n\n[/tt] in that simplest CGI script to [tt]\r\n\r\n[/tt]? //Daniel
 
thanks daniel, but that still gives me the same result.

what effect is it supposed to have?

ss...
 
If it would have been hosted on Windows, the server may not have understood the [tt]\n[/tt] as it is the UNIX way of creating a newline. //Daniel
 
Can you get to a command prompt on the server? If so, check the syntax of your code like,

>perl -c simple.cgi -enter-


Also, can you see the web server error log? If so, what does it say?

'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
no, i can't get to a command prompt on the server.

and the exact error i get in my server error log is:

'[Sat Mar 1 11:53:53 2003] [error] [client 81.131.11.122] Premature end of script headers: /usr/local/psa/home/vhosts/radishdesign.co.uk/cgi-bin/simplest.cgi'

the problem is obviously somewhere in my server environment. when you run a script, what changes do you apply to your environment? i've done everything i mentioned in my first post, but nothing seems to make a difference.

ss...
 
Do you output a HTTP header before you output any actual HTML? That would be the error you would get if you do not.

[tt]print CGI::header;[/tt]

(or you can just print the header directly -- I like using the CGI interface to do it for some unknown reason.)
 
thanks for the help guys, but to be honest, the script isn't really long enough to contain any errors!

here's the script:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print &quot;<HTML><HEAD><TITLE>A NEW CGI PAGE</TITLE></HEAD>\n&quot;;
print &quot;<BODY><P>Hello World</P></BODY></HTML>&quot;;

what i'm really trying to establish is what's missing from my server environment that's preventing the script from executing.

ss...
 
Hi SecretSquirrel,

I copied and pasted your code into my cgi-bin directory and it ran fine. I would guess your server has not be configured to run CGI scripts. Do you know whether your running on an apache web server. If so, the httpd.conf file must be setup correctly. Certain commands like &quot;EXECCGI&quot; and &quot;Include&quot; must be placed in the httpd.conf file before the apache web server will allow server sided includes from CGI scipts. You might check with you system adm. to find out about this. Also, you might check with the apache forum here at Tek-Tips. If you add the following line to your perl scripts, perl errors will be re-directed to you browse, including the line number on which the error occurred. The following code should be placed towards the top of the script.

use CGI qw( :all );
use CGI::Carp qw( fatalsToBrowser );

LelandJ Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Leland123,

Apache doesn't need to be set-up like you described to parse cgi scripts.

The error in the logs conveys that cgi-scripts are alllowed to run in that directory.

Hope this helps Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top