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

What causes 'premature end of script headers'?

by markjugg (Curate)
on May 31, 2003 at 02:12 UTC ( [id://262011]=perlquestion: print w/replies, xml ) Need Help??

markjugg has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

What are possible causes of the 'premature end of script headers' message in a web server's error log after the failed execution of a Perl CGI script?

Originally posted as a Categorized Question.

  • Comment on What causes 'premature end of script headers'?

Replies are listed 'Best First'.
Re: What causes 'premature end of script headers'?
by Aristotle (Chancellor) on May 31, 2003 at 02:30 UTC
    Not having output a header when you should have. Whether that is because the script didn't compile or was aborted before it reached the code to output the header, the result is the same. Consult your server's error log to find out the actual error message.
Re: What causes 'premature end of script headers'?
by markjugg (Curate) on May 31, 2003 at 02:33 UTC
      Something printed to STDERR
      What does STDERR have anything to do with PESH?

      Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Re: What causes 'premature end of script headers'?
by jhourcle (Prior) on Mar 06, 2005 at 20:56 UTC

    Something printing to STDOUT before the headers have been sent, and a blank line has also been sent to mark the end of the headers, or an incorrectly formatted header was sent. You can debug these issues by printing immediately print "Content-type: text/plain\n\n"; and looking at the output that is generated.

    If you're using CGIwrap, you can use the debugging mode to see what content was generated, including the headers. suEXEC can also provide some debugging help.

Re: What causes 'premature end of script headers'?
by solegaonkar (Beadle) on Jul 17, 2012 at 10:32 UTC
    I faced this problem because of DOS end of line characters in the file. Fixed with dos2unix
Re: What causes 'premature end of script headers'?
by LesleyB (Friar) on Oct 29, 2008 at 16:44 UTC

    You might have a bug in your code.

    use CGI::Carp qw(fatalsToBrowser);

    will throw errors up to the browser.

    You can also run cgi scripts from the command line to check they actually run.

Re: What causes 'premature end of script headers'?
by gvs_jagan (Initiate) on Jun 10, 2005 at 12:26 UTC
    You could encounter the 'premature end of script headers'

    1) In case you were trying to accept values from a html page thru textfields

    per se

    print p("enter your name" , textfield("nam","");

    missing out on one of the coats could cause it. For instance

    print p("enter your name", textfield("nam , ""); #the end coat near nam is missing, this could cause

    2) Also if you forget paranthesis near the html headers . In the below mentioned case missing out the paranthesis near the end_html could cause you the error

    print header, start_html() ;
    end_html();# leaving the paranthesis here

    regards jagan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://262011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found