Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > CGI error (need help)

Reply
Thread Tools

CGI error (need help)

 
 
Bernard
Guest
Posts: n/a
 
      11-28-2003
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.co...ostcard1.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


 
Reply With Quote
 
 
 
 
no_guru
Guest
Posts: n/a
 
      11-29-2003
On Fri, 28 Nov 2003 15:26:43 +0100, Bernard wrote:

> 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.co...ostcard1.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,
http://www.aestheticsurgerycenter.co....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






 
Reply With Quote
 
 
 
 
Bernard
Guest
Posts: n/a
 
      11-29-2003
> 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,
> http://www.aestheticsurgerycenter.co....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{'RECIP IENT'}|$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. http://www.velocityreviews.com/forums/(E-Mail 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|$PI CTURES|$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


 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      11-30-2003
Bernard wrote:
> no_guru wrote:
>> 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!

>
> 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/groups?thre....uni-berlin.de

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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
Bernard
Guest
Posts: n/a
 
      11-30-2003

"Gunnar Hjalmarsson" <(E-Mail Removed)> schreef in bericht
news:mmeyb.39970$(E-Mail Removed)...
> Bernard wrote:
> > no_guru wrote:
> >> 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!

> >
> > 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/groups?thre....uni-berlin.de
>
> 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.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>

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


 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      11-30-2003
Bernard wrote:
> Gunnar Hjalmarsson wrote:
>> What you are doing is called multi-posting, and it is very rude.
>> Check the netiquette guidelines for Usenet.

>
> 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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI (read multipart form): Accept-Charset encoding error (CGI::InvalidEncoding) Stefan Fischer Ruby 2 02-23-2010 08:17 AM
(CGI-Target)Could not connect to CGI-Proxy John Smith Java 0 05-15-2006 09:21 PM
Python CGI - Accepting Input, Invoking Another Process, Ending CGI LarsenMTL Python 4 11-04-2004 05:59 PM
Calling cgi from cgi thru 'system' function. Different behaviour on browser v/s cmd line Shailan Perl 2 12-15-2003 04:26 PM
Re: CGI Perl "use CGI" statement fail Jürgen Exner Perl 0 07-31-2003 02:00 PM



Advertisments