Click to See Complete Forum and Search --> : Forum Script Mystery Error ??????


stanton414
04-29-2003, 11:55 AM
I have designed a simple CGI forum. It works fine on my WIN98 Apache server (on my home machine). But whenever i upload it to my webpage i just get Premature End Of Script Errors (no extra error information). Here is the troubled script...


#!/usr/bin/perl -w
use strict;
use CGI qw(:all);

my(%userlist,$username,$password);

sub CreateUser {

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

$username=~tr/`/'/;
$password=~tr/`/'/;

$username=substr($username,0,20);
$password=substr($password,0,20);


dbmopen(%userlist,"userlist",0666)||die "cant make dbmfile: $!";

if (defined $userlist{$username}) {

print redirect (-uri => "/Future/UserExist.shtml");
}else{

$userlist{$username} = $password;

print redirect (-uri => "/Future/forum.shtml");
}

dbmclose(%userlist);

}


CreateUser;



/////////////////////////////////////////////

Help much appreaciated TNX

DaiWelsh
04-30-2003, 09:30 AM
There are many possibilities, but to narrow it down:-

Is the perl location correct for the server you are uploading to (/usr/bin/perl) ?

Do you have permission to create the dbm file.

Note that your die (if you dont have permissions) will not work as is because you are not putting out any headers before the error message.

For debuggin I would recommend either

a) run the script directly on the server using telnet, ssh or similar if you have access to do so.

b) output headers at the top of the page and change your redirects into just prints, then you should at least get back some information in the browser if you die is firing and/or if the script is reaching as far as either of the redirects.

e.g.

print("Content-Type: text/html\n\n<html><body>");

at the top of your scritp and ideally

print("</body></html>");

at the bottom to make it valid html.

If that does not help then I would go to first principles and write a hello world script to run on the server and work forwards from there...


HTH,

Dai

stanton414
04-30-2003, 11:07 AM
I tried puttimg the prints but it didnt work. Still get 500 internal server error. Iv give the script write permissions, the path to perl is 100% correct and iv got other scripts that work.

help me please TNX

stanton414
05-02-2003, 07:05 AM
Iv fixed it now THNX. It was the write permissions in the CGI folder that were wrong. The script itself had the permission but the permissions for the folder it was IN were wrong. just case your interested :)