[Tallahassee-pm] (No subject)

James Tillman jtillman at bigfoot.com
Sun Jan 19 19:26:55 CST 2003


On Sun, 2003-01-19 at 12:40, perl at bay.flrealtor.net wrote:
> This file works on my computer but when I upload it to a unix system and
> try it from the internet it gives me a 500 error.  Can anyone tell me what
> the problem is??  Still new at perl.
> 
> Thanks

Hi.  Welcome to the Tallahassee.pm mail list.  Are you in Tallahassee,
FL or nearby?  Even if not, I'll see what I can do with your problem. 
See below for my notes...
 
> 
>   #!/usr/bin/perl 
>   use CGI qw(:all);
>     use strict;
> 
> print header;
>   print "Directory to search: ";

I assume you comment this next line out when you run it as a CGI.  If
you didn't, it would probably cause problems.

>   my $dir=<STDIN>; chomp $dir;

>    my $dir="/home/lender/nameofdirectory/blankpage";
> 
>   my($file);
> 

This next line is probably your problem.  You see, when you "die" in a
CGI, you get the error 500 message.  You also get error 500 when you
have a syntax error.  Very difficult to debug.

>   opendir(DH, $dir) || die "Cannot open $dir: $!";

>   while ($file=readdir DH) {
>       next if (-d "$dir/$file");
>       if (! open(F, "$dir/$file") ) {
>           warn "Cannot search $file: $!";
>           next;
>       }
> 	open(DEST, "> $file") || die "$!";
>       while(defined($a=<F>)){
> $a=~ s/blankpage/newsite/;
> print DEST $a;
> }
> close(DEST);
>       close(F);
>   }
>   closedir(DH);
> 

Since there are many places your script might be dying or having
problems (due to the change in environment), I would suggest adding the
following line to your script, just below the use CGI; line:

use CGI::Carp qw/fatalsToBrowser/;

This line will load the CGI::Carp module, which will cause "die"
messages or syntax error messages to be sent to the browser, rather than
causing an Error 500.  This might help you to get more info.  If you
need further help after trying that, please let us know what you
discover!  Best of luck.

jpt 




More information about the Tallahassee-pm mailing list