Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Premature end of script

by Phaysis (Pilgrim)
on Aug 13, 2002 at 07:25 UTC ( [id://189720] : note . print w/replies, xml ) Need Help??

in reply to Premature end of script


Several things could happen when you get this error in your server log. Most times, the answer is transparently under your nose. Assuming you are running Perl under Apache on Linux, here is a quick checklist:

First - source code: make sure each line of code in your script is terminated by the proper newline for the platform you're on; if you're on *Nix, use only linefeeds "<LF>", not "<CR><LF>" as you would use on Win32 or "<CR>" as you would use on Mac. Transferring your script via FTP in ASCII mode would solve this.

Second - permissions: make sure your webserver has world-read and world-execute permission to run this script. Try chmod +755.

Third - headers: make sure your script first outputs the proper HTTP headers before any document data is output. One of those headers must be the Content-Type: header, whose value is the mime-type of the document your script outputs (usually "text/html"). The HTTP headers must be seperated from the document body by two linefeeds to tell the server that you are finished outputting the headers. The web server will cough if it cannot determine the mime type; it needs to communicate this to the user agent.

Premature end of script headers is a very vague and confusing term, yes. Bitten me several times. These considerations have always helped me recover.

(Ph) Phaysis
If idle hands are the tools of the devil, are idol tools the hands of god?