Insane "Premature end of script headers"

Insane "Premature end of script headers"

Posted by: AirsickMoth
Posted on: 2007-04-24 13:45:00

I've got PERL scripts running on my site in my /cgi-bin as we speak. Today I tried adding a new one: prints.cgi (the name isn't important, as you'll see). I upload it, chmod 755, try to run it from the web: 500 Internal Server Error. I look in the error.log: Premature end of script headers."

All right. I write a little Hello World script.

#!/usr/bin/perl
print "Hello world!";

I upload that, chmod 755, try to run from the web. 500 error, premature end of script headers.

I telnet in and run it with "perl helloworld.cgi" just to see if it'll run in SSH. It does! But it won't run from the web.

What kills me is I have lots of other scripts currently running in that same /cgi-bin directory that run from both command line and the web, with no trouble. But I can't seem to add a single new one!! Help!

Re: Insane "Premature end of script headers"

Posted by: hcarty
Posted on: 2007-04-24 14:18:00

Try this:

#!/usr/bin/perl

print "Content-type: text/plainnnHello world!";

I think the error is due to the lack of Content-type header information.

Re: Insane "Premature end of script headers"

Posted by: AirsickMoth
Posted on: 2007-04-24 14:28:00

Nope. Still throws 500 from the web, and runs from command line fine (except this time, the output was "Content-type: text/plain Hello world!").

Re: Insane "Premature end of script headers"

Posted by: rlparker
Posted on: 2007-04-24 15:17:00

Don't forget your line endings for cgi output:

#!/usr/bin/perl
print "Content-type: text/htmlnn";
print "<H1>Hello World</H1>n";

note the n entries wink

--rlparker

Tags: premature end of script headersperl scriptschmod 755cgi bin directoryinternal server error500 internal server errorhello worldtry to runusr binworld scriptsshprints