Perl CGI help... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Perl CGI help...

hopefulcdhopefulcd Posts: 1Member
Hi all, I'm having a frustrating error that I'm somewhat confused about. I'm writing a simple perl script as a cgi for a login. I've run through a lot of tests to try to figure out where the error is, but so far it's not been successful. The perl code is as follows:

#!/usr/bin/perl -wT

use CGI;
use CGI::Cookie;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Fcntl qw(:flock :seek);
use Fcntl;
use strict;

my (
$name, #username they type in
$pass, #password they type in
$sys_name, #username in the member file
$sys_pass, #password in the member file
@members, #array of all members
$dirto_members_list, #directory to members file
$valid_name, #variable to determine name validity
$valid_pass, #variable to determine password validity
$cookie #cookie used to dtermine if they're logged in or not
);

$name = param('username');
$pass = param('password');

print header;
print start_html('Login Status');

#########################################################################
# Check the name & password in the members file
#########################################################################

$dirto_members_list = "/home/hopefulc/public_html/cgi-bin/koh_members_list.cgi";

open (MEM, $dirto_members_list) || die("The File could not be opened!"); #open the members file
flock (MEM, LOCK_SH);
seek (MEM, 0, SEEK_SET);
@members = <MEM>;
chomp (@members);

close(MEM); #close the members file

$valid_name = 0;
$valid_pass = 0;

foreach my $mem (@members)
{
($sys_name, $sys_pass) = split (/|..|/, $mem);

if ($name eq $sys_name)
{
$valid_name = 1;

if ($pass eq $sys_pass)
{
$valid_pass = 1;
print "Congratulations $name, you logged in!
<br><br>
";
}
else
{
print "Sorry, you didn't type in the correct password.
<br><br>
";
}
}
}

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

print end_html;


The tests that I've run through include checking the file permissions and setting them to 0755, carefully checking the spelling in the files, checking the html form, and I also ran a slightly modified version of this code from the command line successfully.
The annoying Internal Server error that is in the Apache error log is as follows:

[Mon Jun 16 17:56:46 2008] [error] [client 76.193.171.114] File does not exist: /home/hopefulc/public_html/500.shtml

The error seems very simple, except that I know the file does exist. If anyone has any suggestions to help it would be very much appreciated...
Sign In or Register to comment.