CGI error (need help)

B

Bernard

Hi,

I have a problem with a CGI script (Perl) on a Win2000 server.
The script is for sending E-cards and was written by Jason Maloney:
http://www.aestheticsurgerycenter.com/scripts/postcard/postcard1.shtml
You can choose from some cards, add your own text and send it to a friend.
This friend get a mail which tell him/her that he/she has a mail and have to
click a link.
So far everything works just fine.
But when the recipient clicks the link he/she gets the following error
message in the browser window:
----------------------------------------------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Can't open perl script
"D:\Inetpub\HCO\www\cgi-bin\postcard\card.cgi1070022045": No such file or
directory
--------------------------------------------------------
The cgi script is in \cgi-bin\postcard\card.cgi
But the data it has to retrieve is in
\cgi-bin\postcard\cards\1070022045.dat(for example)
Each mail generates a new .dat file.

Any ideas???
I already had contact with the author, but he tested it only on a Win NT
server which worked just fine. He has no experience with Win2000 server

You can try it on our test site:
http://195.86.135.223/cgi-bin/postcard/index.html

Thanks,
Bernard
 
N

no_guru

Hi,

I have a problem with a CGI script (Perl) on a Win2000 server.
The script is for sending E-cards and was written by Jason Maloney:
http://www.aestheticsurgerycenter.com/scripts/postcard/postcard1.shtml
You can choose from some cards, add your own text and send it to a friend.
This friend get a mail which tell him/her that he/she has a mail and have to
click a link.
So far everything works just fine.
But when the recipient clicks the link he/she gets the following error
message in the browser window:
----------------------------------------------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Can't open perl script
"D:\Inetpub\HCO\www\cgi-bin\postcard\card.cgi1070022045": No such file or
directory
--------------------------------------------------------
The cgi script is in \cgi-bin\postcard\card.cgi
But the data it has to retrieve is in
\cgi-bin\postcard\cards\1070022045.dat(for example)
Each mail generates a new .dat file.

Any ideas???
I already had contact with the author, but he tested it only on a Win NT
server which worked just fine. He has no experience with Win2000 server

You can try it on our test site:
http://195.86.135.223/cgi-bin/postcard/index.html

Thanks,
Bernard

Hey Bernard--

I'm no guru, but I think I can help you with this one...

when you're sending the e-mail to the recipient, the link that it
generates (in this case,
www.aestheticsurgerycenter.com/cgi-bin/postcard/card.cgi1070022045) is
missing a separator for the query string (the 1070022045 part). Find the
portion of the script that puts the message together and add a
question mark between the .cgi and the following varible, and it should work!

hope that helps!

no_guru
 
B

Bernard

Hey Bernard--
I'm no guru, but I think I can help you with this one...

when you're sending the e-mail to the recipient, the link that it
generates (in this case,
www.aestheticsurgerycenter.com/cgi-bin/postcard/card.cgi1070022045) is
missing a separator for the query string (the 1070022045 part). Find the
portion of the script that puts the message together and add a
question mark between the .cgi and the following varible, and it should work!

hope that helps!

no_guru
Here's the code, I have no experience with Perl. So, maybe can you see which
part of the script puts the message together.

#!D:/Program Files/Perl/bin/perl.exe
########################################################
########################################################
# Don't Edit This CGI Part #
########################################################
########################################################

$i=0;
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
if ($ENV{'QUERY_STRING'})
{$buffer = "$buffer\&$ENV{'QUERY_STRING'}";}
@pairs = split(/&/,$buffer);
foreach $pair (@pairs){
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$VALUE{$name} = $value;
}

############################################
#Gets the Current Date
############################################
($sec,$min,$hr,$day,$month,$year,$day_of_week,$day_of_year,$some) =
localtime(time);
@months =
("January","February","March","April","May","June","July","August","Septembe
r","October","November","December");

$year = $year + 1900;

$DATE = "$months[$month]-$day";
$SHORTDATE = "$months[$month] $day, $year at $hr:$min:$sec";

############################################
#Gets Picture Data and Moves on to Next Page
############################################

if ($VALUE{'action'} eq 'preview') {

$pic = $VALUE{'PICTURES'};
$VALUE{'PICTURE'} = $VALUE{'PICTURES'};
$VALUE{'PICTURES'} = "$basepicurl$pic";

print "Content-type: text/html\n\n";
open(TEMPLATE,"$preview1");
&template;
print $template;
exit;
}


#########################
#Prints the Preview Page
#########################
if ($VALUE{'action'} eq 'preview1') {
$pic = $VALUE{'PICTURE'};
$VALUE{'PICTURES'} = "$basepicurl$pic";

$VALUE{'MESSAGE'} =~ s/\r//g;
$VALUE{'MESSAGE'} =~ s/\<[^\>]*\>//ig;
$VALUE{'MESSAGE'} =~ s/"/'/g;
$VALUE{'MESSAGE'} =~ s/\n/<BR>/g;

print "Content-type: text/html\n\n";
open(TEMPLATE,"$preview2");
&template;
print $template;
exit;
}

##########
#Send Card
##########
if ($VALUE{'action'} eq 'send') {
&no_email unless $VALUE{'MAILFROM'} && $VALUE{'MAILTO'};

######################
#Save the Data
######################
$date = time;
$create_card = "$cards$date.dat";

open(DATA, ">>$create_card");
print DATA
"$VALUE{'SENDER'}|$VALUE{'MAILFROM'}|$VALUE{'RECIPIENT'}|$VALUE{'MAILTO'}|$V
ALUE{'MESSAGE'}|$VALUE{'PICTURE'}|0\n";
close(DATA);

$url_of_card = "$cgi?$date";

##########################
#Print Thank You HTML
##########################
print "Content-type: text/html\n\n";

open(TEMPLATE,"$thank_you");
&template;
print $template;

$template = '';

##########################
#Send E-mail to Recipient
##########################

open (MAIL, "|$mailprog -t") || die "Kan $mailprog niet openen!\n";
print MAIL "To: $VALUE{'MAILTO'} ($VALUE{'RECIPIENT'})\n";
print MAIL "From: $VALUE{'MAILFROM'} ($VALUE{'SENDER'})\n";
print MAIL "Subject: $VALUE{'RECIPIENT'}, $subject1\n\n";

open(TEMPLATE,"$email1");
&template;
print MAIL $template;

print MAIL ".\n" ;
close(MAIL);

$deletes = "$cards$DATE.dat";

if(-e $deletes){
}
else{
open(DATA, ">>$deletes");
close(DATA);
&delete;
}
exit;
}

########################
#No E-Mail Addresses
########################
sub no_email {
print "Content-type: text/html\n\n";
print "<HTML>\n<TITLE>Fout! E-Mail adres niet geldig</TITLE>\n";
print "<BODY COLOR=\"#FFFFFF\">\n";
print "Kan niet verstuurd worden!<BR>\n";
print "<B>[Mogelijke oorzaken:]</B><BR>\n";
print "&nbsp;&nbsp;1.) U bent beide e-mail adressen vergeten in te
vullen<BR>";
print "&nbsp;&nbsp;2.) E-Mail Adres(en) niet in de goed formaat ingetypt,
<B>b.v. (e-mail address removed)</B>";
exit;
}

#######################################
#Creates the Postcard
#######################################
if ($ENV{'QUERY_STRING'}) {

############################################
#Makes Postcards and Sends Thank You E-mail
############################################
$create_card = "$cards$ENV{'QUERY_STRING'}.dat";

if(-e $create_card){
open(DATA, "$create_card");
@data = <DATA>;
close(DATA);

foreach $temp (@data){
chop($temp);
($SENDER, $MAILFROM, $RECIPIENT, $MAILTO, $MESSAGE, $PICTURES, $COUNT) =
split(/\|/, $temp);

$VALUE{'SENDER'} = $SENDER;
$VALUE{'MAILFROM'} = $MAILFROM;
$VALUE{'RECIPIENT'} = $RECIPIENT;
$VALUE{'MAILTO'} = $MAILTO;
$VALUE{'MESSAGE'} = $MESSAGE;
$VALUE{'MESSAGE'} =~ s/ /&nbsp; /g;
$VALUE{'PICTURES'} = "$basepicurl$PICTURES";
$VALUE{'LINK'} = "$link$LINK";
$VALUE{'PICTURE'} = "$basepicurl$PICTURES";
}

unlink("$create_card");

open(DATA, ">>$create_card");
$COUNT++;
print DATA
"$SENDER|$MAILFROM|$RECIPIENT|$MAILTO|$MESSAGE|$PICTURES|$COUNT\n";
close(DATA);

print "Content-type: text/html\n\n";
open(TEMPLATE,"$makecard");
&template;
print $template;

$template = '';

if($COUNT eq '1'){
open (MAIL, "|$mailprog -t") || die "Kan $mailprog niet openen!\n";
print MAIL "To: $VALUE{'MAILFROM'} ($VALUE{'SENDER'})\n";
print MAIL "From: $VALUE{'MAILTO'} ($VALUE{'RECIPIENT'})\n";
print MAIL "Subject: $subject2\n\n";

open(TEMPLATE,"$email2");
&template;
print MAIL $template;

print MAIL ".\n" ;
close(MAIL);
}
}
else {
print "Content-type: text/html\n\n";
open(TEMPLATE,"$error");
&template;
print $template;
}
exit;
}

#######################################
#DELETES the information
#######################################
sub delete {

local(@items, $pair);
opendir(DELETE, "$cards");
@items = grep(/.dat/,readdir(DELETE));
closedir(DELETE);
foreach $pair (@items){
if (-M "$cards$pair" > $MAX_DAYS){
unlink("$cards$pair");
}
}
}

#####################
#Calls the Template
#####################

sub template {
while (<TEMPLATE>){
$template .= $_;
}
close(TEMPLATE);

$template =~ s/\%%%PICTURES%%%/$VALUE{'PICTURES'}/g;
$template =~ s/\%%%PICTURE%%%/$VALUE{'PICTURE'}/g;
$template =~ s/\%%%SENDER%%%/$VALUE{'SENDER'}/g;
$template =~ s/\%%%MAILFROM%%%/$VALUE{'MAILFROM'}/g;
$template =~ s/\%%%MAILTO%%%/$VALUE{'MAILTO'}/g;
$template =~ s/\%%%RECIPIENT%%%/$VALUE{'RECIPIENT'}/g;
$template =~ s/\%%%MESSAGE%%%/$VALUE{'MESSAGE'}/g;
$template =~ s/\%%%CGI%%%/$cgi/g;
$template =~ s/\%%%MAX_DAYS%%%/$MAX_DAYS/g;
$template =~ s/\%%%SHORTDATE%%%/$SHORTDATE/g;
$template =~ s/\%%%url_of_card%%%/$url_of_card/g;
}


Thx,
Bernard
 
G

Gunnar Hjalmarsson

Bernard said:
Here's the code, I have no experience with Perl. So, maybe can you
see which part of the script puts the message together.

Dear Bernard,

It's very annoying to notice that you post the code here too, while
ignoring the help I tried to give you in another group:

http://groups.google.com/[email protected]

On top of it, in this group you didn't post the part of the code that
I suspect is causing the problem.

What you are doing is called multi-posting, and it is very rude. Check
the netiquette guidelines for Usenet.
 
B

Bernard

Gunnar Hjalmarsson said:
Dear Bernard,

It's very annoying to notice that you post the code here too, while
ignoring the help I tried to give you in another group:

http://groups.google.com/[email protected]

On top of it, in this group you didn't post the part of the code that
I suspect is causing the problem.

What you are doing is called multi-posting, and it is very rude. Check
the netiquette guidelines for Usenet.
Dear Gunnar,

I'm very sorry for this, but here at home my provider doesn't support this
newsgroep. I thought I only could check it on monday on my work for your
answers/effort.
With the link you gave me now, I can read your answer and I wil try it right
away.
When something goes wrong, I try to get help where available. But it was not
ment to overrule somebody.
I was/am really please with your help.

Bernard
 
G

Gunnar Hjalmarsson

Bernard said:
I'm very sorry for this,

It's okay, now you know something about Usenet that you didn't know
before. ;-)
but here at home my provider doesn't support this newsgroep.

Do they support comp.lang.perl but not alt.perl? They'd better do it
the other way around, because comp.lang.perl is actually defunct.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top