Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Premature end of script headers

Status
Not open for further replies.

salc76

Technical User
Feb 21, 2007
21
CA
I installed an apache server on Redhat 8.0. Most CGI scripts that I run fail. I receive the following message from the server.

Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: assi1final.cgi
If you think this is a server error, please contact the webmaster
Error 500

However, running the follwing script works fine,

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

How can I correct this problem? Any ideas??

Sal
 
shebang line might be wrong, try it without the initial forward slash and no switches:

#!usr/bin/perl

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Kevin, could the problem be a configration issue? That means apache server does not know a perl code with a extention '.cgi'?
 
actualy, I miss-read the first post, salc76 said:

>>However, running the follwing script works fine,

so the shebag line must be OK.

It could be a problem with the extension.





------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Are you saying to change the extension of the script from .cgi to .pl?

The following is a simple script that works:

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



The following is a simple script that produces the above stated error:

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

print header;
print start_html("Thank You");
print h2("Thank You");

my %form;
foreach my $p (param()) {
$form{$p} = param($p);
print "$p = $form{$p}<br>\n";
}
print end_html
 
can you check the server error logs? You might see something about "can't locate CGI.pm in @INC" in which case there is a problem with the script finding the CGI module.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Your right. Take a look at the following error log that was generated,

[Tue Apr 17 17:35:07 2007] [error] [client 192.168.1.120] Can't locate CGI.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0) at /var/ line 3.

Ho do I fix this?
 
CGI.pm has been a core module for a long time. You can try installing it if you wanted too but if you have a tech suport person to ask that might be better. Maybe they deleted CGI.pm for a reason.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top