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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

500 error, premature end of script headers

Status
Not open for further replies.

random260

Programmer
Mar 11, 2002
116
US
I've fried my brain dealing with my new web host - after arguing with them for three weeks telling them SOMETHING was wrong on their end with my cgi (and having them keep saying "no there isn't" and me roasting my brain trying to figure out what i had done wrong), they finally fixed it, and at least 1/2 my scripts run. But some of them (like this one) will not - and the exact same script works on my other web sites (I just change the location of perl, sendmail, etc). I am getting the error 500 "Premature end of script header". I can see nothing wrong with this script - can some take a quick peek for me please?
Thanks

#!/usr/bin/perl5 -w
use strict;
use CGI qw:)all);
use CGI::Carp qw(fatalsToBrowser);
$|=1;

# use Fcntl qw:)flock);

sub send_mail {
my($to, $from, $subject, @detail, @iknow, @jbefore, @comments)=@_;
my $sendmail="/usr/sbin/sendmail -t -oi";
open(MAIL, "|$sendmail") || die "Can't start sendmail: $!";
print MAIL<<END_OF_HEADER;
from: $from
to: $to
subject: $subject

END_OF_HEADER

print MAIL &quot;User information\n\n&quot;;

my $name = param(&quot;name&quot;);
print MAIL &quot;Contact name: $name\n&quot;;

my $email=param(&quot;return_addr&quot;);
print MAIL &quot;Email address: $email\n\n&quot;;


print MAIL &quot;Problem report\n\n&quot;;

print MAIL &quot;Problem is with software or hardware?\n&quot;;
my $event = param(&quot;event&quot;);
print MAIL &quot;$event\n\n&quot;;

print MAIL &quot;User thinks problem might be\n&quot;;
my $problem = param(&quot;problem&quot;);
print MAIL &quot;$problem\n\n&quot;;

print MAIL &quot;The problem started\n&quot;;
my $start = param(&quot;start&quot;);
print MAIL &quot;$start\n\n&quot;;

print MAIL &quot;Problem details\n\n&quot;;
foreach (@detail) {
print MAIL &quot;$_\n&quot;;
}
print MAIL &quot;\n&quot;;

print MAIL &quot;User thinks problem may have been caused by\n\n&quot;;
foreach (@iknow) {
print MAIL &quot;$_\n&quot;;
}
print MAIL &quot;\n&quot;;

print MAIL &quot;Was anything installed/changed right before problem started?\n\n&quot;;
foreach (@jbefore) {
print MAIL &quot;$_\n&quot;;
}
print MAIL &quot;\n&quot;;

print MAIL &quot;Additional comments and information\n\n&quot;;
foreach (@comments) {
print MAIL &quot;$_\n&quot;;
}
print MAIL &quot;\n&quot;;

close(MAIL);
}

print header;
my $return=param(&quot;return_addr&quot;);
if (! defined $return or ! $return) {
print &quot;You must supply an email address<P>&quot;;
exit;
}
my $subject=param(&quot;subject&quot;);
if (! defined $subject or ! $subject) {
print &quot;You must supply an subject<P>&quot;;
exit;
}

send_mail('me@myweb.com',
$return,
$subject,
param(&quot;body&quot;));

my $priority = param(&quot;priority&quot;);
if ($priority==&quot;High&quot;) {
print header;
my $return=param(&quot;return_addr&quot;);
if (! defined $return or ! $return) {
print &quot;You must supply an email address<P>&quot;;
exit;
}
my $subject=param(&quot;subject&quot;);
if (! defined $subject or ! $subject) {
print &quot;You must supply a subject<P>&quot;;
exit;
}

send_mail('me@myweb.net',
$return,
$subject,
param(&quot;body&quot;));
}

print &quot;Mail sent.&quot;;
 
Try
putting
Code:
print &quot;Content-Type: text/html\n\n&quot;; [code]
as the first executable line after your use statements

HTH
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
That didn't work, same error - any other suggestions?
 
You have carp(fatalsToBrowser) what's the exact error
Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top