If you get a server-generated error page when trying to access your CGI, there is usually a string which explains why the script generated an error. The most common are:
This is probably the most common error which is seen, both during development and in production. To better explain this error, it helps to have some background on what the web server expects a CGI to return.
The basic stucture of a CGI's response is:
For most applications, the mime-type is set to
text/html, since HTML is the most common content returned to the browser. The CGI can add as many other headers as it needs, or just specify the content type. Following the last header is a blank line, and the content follows that blank line.
Apache, which is the web server used on www.washington.edu, will generate an error of Premature end of script headers if it does not see the blank line. Some cases which will create this error are:
#!syntax. to specify which binary to use and that binary doesn't exist, or because the script is not executable (usually you would see "file permissions deny server execution", but this error will also appear sometimes.)
exit()system call, or as another example, a Perl script reached an error from which it could not recover.
Looking again at the format of CGI output, we can see that this error message will occur if the script displayed content and no headers; that content should show up as text in the error.
Another possible cause for this error message is if no blank line was output after the headers and before the content.
Unlike the other errors, this is a message displayed by some browsers as a dialog box. Since the server didn't display an error about the headers ending prematurely, that means that the headers were fine. However, if the script exits after the headers and blank line, but before any content, then the browser has no content to display, and therefore will show this message.