I looked up to see what the server
error log was saying.  This is what it has:
Premature end of script headers: /home/donmike/www/cgi-bin/file.cgi

I live in Panama City, Fl.  As you can see, I am kinda new at using perl.
I have taken courses on C++, so I do understand some of the commands.

Any help would be great, as I have spent over 5 hours trying to make this
work.  Maybe you have a different way to do what I am trying to acomplish.

I have a directory with about 150 text files and html files and I want to
replace certain words.  For example:

<a href="http://www.panamacityrealtors.com/jimmy/contact.html";
target=rightbottom>

This link maybe in 100 different files and I would like to replace the word 
jimmy with a differnt word, like bob.

So I use the this command to do it

$a=~ s/jimmy/bob/;

It works if I do perl file.cgi on the command line but not over the
interent.  I hope, I have given you plenty of information on what I am
trying to acomplish.  

Any help would be great.

Thanks alot for your time.

Mike


----- Original Message -----
From: "James Tillman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 19, 2003 7:26 PM
Subject: Re: [Tallahassee-pm] (No subject)


On Sun, 2003-01-19 at 12:40, [EMAIL PROTECTED] 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



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to