Baz-

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.

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


In reply to Re: Premature end of script by Phaysis
in thread Premature end of script by Baz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.