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!

errors in small perl script

Status
Not open for further replies.

random260

Programmer
Mar 11, 2002
116
US
I have not programmed in perl in about 2 years, so I'm hoping someone here can look at this real quick and find that I have made a stupid mistake. I modified this from a script I made a while ago - that script worked. When I run this as debug (perl -c mailer.cgi) perl says the syntax is OK. For the first couple of debug runs I got some sort of message I didn't write down about unterminated string end_of_header (or something like that) - all I did was cut out a line that said end_of_header, then pasted it back in, and the next
perl -c mailer.cgi run said syntax ok. But when I try to run it on the sever I get an internal server error
"The server encountered an internal error or misconfiguration and was unable to complete your request." The server logs say error 500, 606, and premature end of header. Here is the script:

#!/usr/bin/perl5 -w

use strict;

use CGI qw:)all);

use CGI::Carp qw(fatalsToBrowser);



# use Fcntl qw:)flock);



sub send_mail {

my($to, $from, $subject, @details)=@_;

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 "Tournament entry request\n\n";



my $name = param("name");

print MAIL "$name\n";



my $address = param("address");

print MAIL "$address\n";



my $city = param("city");

print MAIL "$city,";



my $state = param("state");

print MAIL "$state ";



my $zip = param("zip");

print MAIL "$zip\n";

my $phone = param("phone");

print MAIL "$phone\n";

my $email=param("return_addr");

print MAIL "$email\n\n";

print MAIL "Member?\n";

my $member = param("member");

print MAIL "$member\n\n";

print MAIL "Please enter me into the following tournament(s)\n";

my $event = param("event");

print MAIL "$event\n\n";



print MAIL "Additional comments\n\n";

foreach (@details) {

print MAIL "$_\n";

}

print MAIL "\n";



close(MAIL);

}



print header;

my $return=param("return_addr");

if (! defined $return or ! $return) {

print "You must supply an email address<P>";

exit;

}

my $subject=param("subject");

if (! defined $subject or ! $subject) {

print "You must supply an subject<P>";

exit;

}



send_mail('softech@sover.net',

$return,

$subject,

param("body"));





print "Mail sent.";

Thanks
Steve
 
Have you checked the ownership and permissions on the file?
--Paul

cigless ...
 
Permissions on the cgi-bin folder and the mailer.cgi file are both 775.
 
Check the webserver logs, particularly error_log, and tell us what it says,
or add this line to your script
Code:
use CGI::Carp qw /fatalsToBrowser/;
and let us know what that says

cigless ...
 
If you look at the script you'll see that line is already there... the log says

[Sat Jul 9 10:32:26 2005] [error] [client 192.168.50.128] Premature end of script headers: /home/woodburygolf/Files/cgi-bin/mailer.cgi
 
try running it on the command line to see what you get
Code:
perl mailer.cgi member='member1' state='Of Mind' ...

Sorry about scanning your post, should've taken more time to read

HTH
--Paul


cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top