PDA

View Full Version : Premature end of script headers


rizwan65
05-01-2005, 09:02 AM
ERROR 500
Premature end of script headers: test.cgi

I see this error message this all over the 'net, and I've fixed the obvious (chmod 777 for the directory and the objects, made sure the...

#!/usr/bin/perl
print "Content-type: text/html\n\n";

...is followed by a blank line.

The script works from a command line but this error comes back from a browser.

This is FedoraCore 1 with Apache version 2.0.50 and perl v5.8.3 ... am I missing something in either the perl or httpd config, maybe?

Any suggestions

Rizsh

netroact
05-01-2005, 08:20 PM
That's a general error that could mean anything. Did you try running fatals to browser?



use CGI::Carp qw(fatalsToBrowser);



This should give a more specific error message.

rizwan65
05-01-2005, 08:45 PM
Well netroact,
Below is the code


#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);

print "Content type: text/html\n\n";
print "<html><head><title>This is a URL test</title></head>";
print "<body>This is a URL test</body></html>";

exit 1;

Same error in browser and the error_log also shows same error


[Mon May 02 00:40:02 2005] [error] [client 203.31.156.41] Premature end of script headers: test.cgi

Jeff Mott
05-01-2005, 09:37 PM
print "Content type: text/html\n\n";You're missing the hyphen. Content-type.

netroact
05-01-2005, 10:09 PM
I just copied and pasted your code on mine, and it worked just fine, so I sure don't know.

rizwan65
05-04-2005, 07:52 PM
Well
I tried the same test.cgi on my server's cgi-bin and it worked
but if I use it in the cgi-bin of Virtual site it didn't works

e.g.
1. http://my.ip.address/cgi-bin/test.cgi (Works)

2. http://mysites.com/cgi-bin/test.cgi (Same error Premature end of script headers: test.cgi)

I think it is some sort of Apache Configuration issue but I don't know how to solve it

Any suggestions