[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
other CGI problem
Hi,
I have also a problem with CGI scripts in general :
I red all the threads about that subject without
finding an answer to my pb.
My script is a "sendmail" script, it normally send a form
to me by E-mail. it's been written by professionals (as
I don't know anything about Perl).
I installed Perl for Windows 95 on my machine, tested it,
it works well with the "hello.pl" script.
I also installed a "sendmail" program for Windows which
works excatly the same way that the Unix version.
I also tried it and it works fine.
Then I made a form where I give the name of my Perl
script in the "ACTION=" tag. I also defined some
hidden fields (mailto and subject) to give the script
the appropriate parameters.
Here's the error I got from the server :
500 Internal Server Error
The server encountered an internal error while processing this
request.
The following error messages were logged during this request:
[Wed Oct 21 14:17:42 1998 GMT] CGI: Error reading response headers
from CGI program.
Start of command line is 'c:\pi3web\cgi-bin\perl\bin\perl
C:\PI3WEB\Cgi-Bin\mailform.cgi '.
I checked all the configuration parameters in config.pi3.
I don't understand what happens, I suppose there's something
in the script that does not work fine, but as I don't know Perl...
Here's the script, it's a bit complicated but I hope you'lle be able
to tell me what's wrong. Thanx for any help.
Laurent.
P.S.: I'm on an Intranet but I work locally for the moment.
My computer uses Windows 95.
---------------------------------------------
!/cgi-bin/perl
# mailform.cgi
$MAIL="/cgi-bin/sendmail -t";
#sendmail is installed in C:\PI3WEB\CGI-BIN
use CGI;
$\="\n";
$req=new CGI;
print $req->header;
# THE MAIN EVENT
# -------------------
%fields=&read_fields;
&send_form;
&print_thanks_page;
exit(0);
# SUBROUTINES
# -------------------
sub read_fields{
my(%fields);
foreach $f ($req->param){
$name=&clean_name($f);
$fields{$f}{name}=$name;
$value=&clean_value($f);
$fields{$f}{value}=$value;
}
return(%fields);
}
sub clean_name{
local($f)=shift;
$f=~s/^F\d+_//;
$f=~s/_/ /g;
return($f);
}
sub clean_value{
local($f)=shift;
local(@val,$val);
@val=$req->param($f);
$#val-- unless $val[-1]=~/\S/;
$val=join(" - ",@val);
return($val);
}
sub send_form{
return unless $fields{'mailto'}{'value'}=~/^[\w-]+@(modicon)\.com$/;
#MODICON.COM is the name of my SMTP server.
open(MAIL,"| $MAIL") or error("can't send mail");
print MAIL "To: $fields{'mailto'}{'value'}";
print MAIL "From: $fields{'Name'}{'value'} <$fields{'E-mail'}{'value'}>";
print MAIL "Reply-To: $fields{'E-mail'}{'value'}";
print MAIL "Subject: $fields{'subject'}{'value'}";
print MAIL "";
# the fields NAME, E-MAIL, SUBJECT and MAILTO exist in my html page.
$\="";
$,=" - ";
foreach $f (sort keys %fields){
next unless $f=~/^F\d/;
if ($fields{$f}{name} =~ /Comment/i) {
print MAIL "\n";
print MAIL "$fields{$f}{value}";
print MAIL "\n";
}
else{
print MAIL "$fields{$f}{name}: ";
print MAIL ($fields{$f}{value} ? $fields{$f}{value} :
@{$fields{$f}{'values'}});
print MAIL "\n";
}
}
$,="";
close(MAIL);
}
sub print_thanks_page{
$\="";
print <<"EOM";
<HTML>
<HEAD>
<TITLE>Thanks for your input</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<h2>Thanks for your input!</h2>
Thanks for taking the time to fill out our form. If necessary, we will contact
you at the e-mail address you provided, $fields{'E-mail'}{'value'}.
</BODY>
</HTML>
EOM
}