CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
500 Internal server error... Why ?

 



marco
Novice

Jun 16, 2004, 1:33 PM

Post #1 of 4 (782 views)
500 Internal server error... Why ? Can't Post

When I try to delete a user from my cancel.dat. ( Using my sub deletelog) I get an 500 internal error message. The user gets deleted from my file... But I would like to get rid of that error message ( And understand why I am getting it. )



Anyone can find why ?

###############################################################

#!/usr/bin/perl -wT

use CGI::Carp qw(fatalsToBrowser);
use diagnostics;
use CGI;


my $query = CGI->new();
my @names = $query->param;


my $remove = $query->param( remove );
my $efface = $query->param( efface );

if ($efface eq 'yes') {&deletelog;}
else { &printpage;}


exit;


############################################################################
sub printpage

{
open INPUT, "/usr/home/jonjovi/www.domain.com/cgi-bin/log/cancel.dat" or &impossible;
my @lines = <INPUT>;
close INPUT;
print "Content-type: text/html\n\n";

print "<body bgcolor=\"#660000\" text=\"#000000\">\n";

print "<CENTER><h4><font color=\"#FFFFFF\">Ventes qui doivent être cancellé du recurring </font></h4>\n";

print "<TABLE BORDER=0 width=\"100%\" CELLSPACING=3 CELLPADDING=3>\n";

print "<TR BGCOLOR=\"#CC9966\"><TH><FONT face=Arial,Helvetica size=-1>Date</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>Nom</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>Email</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>Nom du site</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>numero de carte</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>numero de Order ID</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>Bank Approval</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>Bank transaction ID</FONT></TH><TH><FONT face=Arial,Helvetica size=-1>Effacer du log</FONT></TH></TR>\n";

foreach (@lines) { #build hash of affiliates
chomp;
my ($date,$cardholder,$Email,$siteNAME,$cardnumber,$response_order_id,$bank_approval_code,$bank_transaction_id) = split(/\|/,$_);

$dateread = localtime $date;


{ print "<TR BGCOLOR=\"#FFFFFF\"><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$dateread</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$cardholder</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$Email</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$siteNAME</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$cardnumber</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$response_order_id</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$bank_approval_code</FONT></TD><TD>&nbsp;<FONT face=Arial,Helvetica size=-1>$bank_transaction_id</FONT></TD><TD><a href=\"https://www.domain.com/cgi-bin/pending_cancel.pl?efface=yes&remove=".&escape($_)."\"\"><font color=\"#0033FF\">Effacer</font></a></TD></TR>\n";



}
}
print "</TABLE></CENTER>\n";
exit;

}

#-------------------------------------------
sub escape {
my($toencode) = @_;
$toencode=~s/([^a-zA-Z0-9_\-. ])/uc sprintf("%%%02x",ord($1))/eg;
$toencode =~ tr/ /+/; # spaces become pluses
return $toencode;
}


#--------------------------------------------

sub impossible {
print "Content-type: text/html\n\n";
print "Impossible d'ouvrir le fichier pendinsale.dat\n";

exit;
}

#####################################################################################################

sub deletelog
{
open INPUT, "/usr/home/jonjovi/www.domain.com/cgi-bin/log/cancel.dat"; #read in order log
my @lines = <INPUT>;
close INPUT;

my $remove=$query->param( remove );
open OUTPUT, ">/usr/home/jonjovi/www.domain.com/cgi-bin/log/cancel.dat";
&lock (\*OUTPUT);
foreach my $line (@lines) {
chomp $line;
if ($line ne $remove) { #replace all except this user
print OUTPUT "$line\n";
}
}
&unlock(\*OUTPUT);
close OUTPUT

&deleted;

}

#------------------------------------------
sub lock {
my $file = shift;
flock($file,2) or &nolock;
# and, in case someone appended while we were waiting...
seek($file, 0, 2) &nolock;
}
#------------------------------------------

sub unlock {
my $file = shift;
flock($file,8) or &nounlock;
}
#--------------------------------------------

sub nolog {
print "Content-type: text/html\n\n";
print "Log d'informations a echoue\n";

exit;
}

############################################################################################################


sub deleted {
print "Content-type: text/html\n\n";
print "Efface !\n";

exit;
}


microwebber
Novice

Jun 16, 2004, 6:16 PM

Post #2 of 4 (774 views)
Re: [marco] 500 Internal server error... Why ? [In reply to] Can't Post

try this at the beginning of the script

BEGIN{open(STDERR, ">./err.txt");}



or look at the error logs for your server
Thanks
Tricia
yourkeylady@earthlink.net


marco
Novice

Jun 16, 2004, 9:55 PM

Post #3 of 4 (769 views)
Re: [microwebber] 500 Internal server error... Why ? [In reply to] Can't Post

Hi !

I tried but it didn't work Unsure
I get exactly the same error.


davorg
Thaumaturge / Moderator

Jun 17, 2004, 1:17 AM

Post #4 of 4 (768 views)
Re: [marco] 500 Internal server error... Why ? [In reply to] Can't Post

If you get an internal server error page then the real error will be written to the web server error log. What do you see in there?

Alternatively, you can try running your program from the command line to see what errors it gives. I just tried that and it gave a couple of pages of warning messages which were pretty easy to fix.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives