Mailing List Archive

malformed header from script - What does this mean?
I've got a simple Form. It gets a single text variable from the user.
It posts to a Perl script. The script mails the form to a designated user
(me). All of this takes place, then gives Server Error.

If I look in /usr/local/etc/httd/logs/error_log it says "malformed header
from script". Any ideas?

Thanx,
RAK

PS - Here's the svy.html

<HTML>
<HEAD>
<TITLE>Form</TITLE>
</HEAD>
<BODY>
<H1>Customer Satisfaction Survey</H1>
We would very much like to have your thoughts
on the services we provide. Please help us out
by filling out this form and submitting it.
<HR>
<FORM METHOD=POST
ACTION="http://www.ccsales.com/cgi-bin/svy.pl">
<P>
<CENTER><I><H2>Optional Information</H2></I></CENTER>
<PRE>
Your Name: <INPUT TYPE="text" NAME="name" SIZE="20">
<HR>
<P>
<INPUT TYPE="submit" VALUE="Send in the survey!">
</FORM>
</BODY>
</HTML>

Here's the svy.pl:

#!/usr/bin/perl
#Includes cgi-lib file; if cgi-lib doesn't exist, returns malformed
#header error
do "cgi-lib.pl" || die "Fatal Error: Can't load cgi library";
#calls the subroutine in the cgi-lib.pl library
#to read in the variables from the form and set them up
#as key=value pairs in the array
&ReadParse;
#tells http server incoming data is text html
print "Content-type: text/html";
#returns acknowledgment of mail submission and provides a link back
#print "<HTML>";
#print "<HEAD><TITLE>Thank You\!</TITLE>";
#print "</HEAD><BODY>";
#print "<H2>Thank you\!</H2>";
#print "We value your input highly\!";
#print "<P>";
#print "We've mailed off your survey to\n";
#print "be collated as soon as possible\n";
#print "<HR>";
#print "<H3>Back to the <A HREF=\"/index.html\">";
#print "Front Page</A></H3>";
#print "</BODY></HTML>";
#assigns process id to $pid
$pid=$$;
#opens up comment file for writing
open(COMMENTSFILE,"> /tmp/my_comment.$pid");
#enter the form data into the file to be mailed
print COMMENTSFILE "CUSTOMER SATISFACTION SURVEY REPORT\n";
print COMMENTSFILE "- - - - - - - - - - - - - - - - - -\n";
print COMMENTSFILE "optional information:\n";
print COMMENTSFILE " Name: $in{'name'}\n";
#close out file to be mailed
close COMMENTSFILE;
#sends comment file as mail to user
$command="mail randyk\@ccsales.com < /tmp/my_comment.$pid";
system($command);
#erases temp file
#unlink("my_comment.$pid");
Re: malformed header from script - What does this mean? [ In reply to ]
Hi Randy,

> [...]
> If I look in /usr/local/etc/httd/logs/error_log it says "malformed header
> from script". Any ideas?
>
> Here's the svy.pl:
>
> #!/usr/bin/perl
> [...]
> print "Content-type: text/html";

Change this line to be:

print "Content-type: text/html\n\n";

The double newlines are required.

regards,
neilb