Page Index Toggle Pages: 1 Print
CGI application misbehaved (Read 5971 times)
Captain John
Ex Member


CGI application misbehaved
Jul 28th, 2008 at 3:23pm
Print Post  
**********************************************************
Quote:
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
Basically a 500 ISE error. Often caused by servers with very low timeout values for CGI scripts, or for servers that doesn't display proper error information when a 500 ISE occurs. In the latter case, it is often caused by a corrupt file in the Variables or Sources directory, and can often be diagnosed by this trick:

Code
Select All
#!/usr/bin/perl

CGI::Carp qw(fatalsToBrowser); 



##############################

or Error Display Script

Code
Select All
#!/usr/bin/perl

BEGIN {
    $| = 1;
    open (STDERR, ">&STDOUT");
    print "Content-type: text/plain\n\n<PRE>";
} 


#############################
« Last Edit: Feb 22nd, 2010 at 8:33pm by »  
Back to top
 
IP Logged
 
Captain John
Ex Member


Re: CGI Error
Reply #1 - May 13th, 2009 at 5:43pm
Print Post  
Premature end of script headers:

The "Premature end of script headers" error message is probably the most loathed and common error message you'll find.
What the error actually means, is that the script stopped for whatever reason before it returned any output to the web server.
A common cause of this for script writers is to fail to set a content type before printing output code. In Perl for example, before printing any HTML it is necessary to tell the Perl script to set the content type to text/html, this is done by sending a header, like so:

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

If you don't do that, Perl will try to output to STDOUT (Standard Output, or the servers terminal) instead of through the web server to your browser.
The same applies to any CGI script of any language.

The problem might be the script itself, for example, say you have a formmail type script that is trying to send an e-mail to sendmail on the server, but the path to sendmail in the script is wrong or has passed bad parameters. The script should die at this stage and print an error message to the server error log, saying that it was "unable to open sendmail" or some such error, but you will see an error like "Internal Server error" or "Premature end of script headers" because printing detailed error messages to an unknown users browser is giving to much potentially damaging information away to possibly untrustworthy people.

With Perl there is something you can try that will attempt to redirect error messages to the browser so you can attempt to diagnose the problem.
Open the script in your text editor, and under the path to Perl on the first line, place this:

use CGI::Carp qw(fatalsToBrowser);

Then upload the script again, set it to executable and point your browser at it. If all goes according to plan, the error message will now be printed to the browser for all to see. Fix the error it details, and then comment out (or remove) that line because its never a good idea to give server settings out.

We are sorry, but there is no quick and easy explanation for this error. Simply because all the error really says is "it didn't work". So in short the answer may be simple, but this error message isn't going to tell you what it is. Permissions, ascii & binary file uploading and script configuration (are the required files where the config says they should be?) are the things most likely to cause such an error.
  
Back to top
 
IP Logged
 
Captain John
Ex Member


Re: CGI Error
Reply #2 - May 13th, 2009 at 5:48pm
Print Post  
Errors may occur when you run CGI applications on a fast multi-processor computer that is running IIS 5.0 and IIS 6.0

http://support.microsoft.com/default.aspx?scid=kb;EN-US;884764
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Print
 
  « Board Index ‹ Board  ^Top