From perl at bay.flrealtor.net Sun Jan 19 11:40:31 2003 From: perl at bay.flrealtor.net (perl@bay.flrealtor.net) Date: Mon Aug 2 21:37:57 2004 Subject: [Tallahassee-pm] (No subject) Message-ID: <1042998031.webmail@bay.flrealtor.net> 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 #!/usr/bin/perl use CGI qw(:all); use strict; print header; print "Directory to search: "; my $dir=; chomp $dir; my $dir="/home/lender/nameofdirectory/blankpage"; my($file); 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=)){ $a=~ s/blankpage/newsite/; print DEST $a; } close(DEST); close(F); } closedir(DH); From perl at bay.flrealtor.net Sun Jan 19 12:56:25 2003 From: perl at bay.flrealtor.net (perl@bay.flrealtor.net) Date: Mon Aug 2 21:37:57 2004 Subject: [Tallahassee-pm] Fw: (No subject) Message-ID: <1043002585.webmail@bay.flrealtor.net> Ok, found out why I am getting this error... Premature end of script headers???? What does that mean?? Anyone? 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 #!/usr/bin/perl use CGI qw(:all); use strict; print header; print "Directory to search: "; my $dir=; chomp $dir; my $dir="/home/lender/nameofdirectory/blankpage"; my($file); 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=)){ $a=~ s/blankpage/newsite/; print DEST $a; } close(DEST); close(F); } closedir(DH); -----Original Message----- From: perl@bay.flrealtor.net Sent: Sun, 19 Jan 2003 12:40:31 EST Subject: (No subject) 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 #!/usr/bin/perl use CGI qw(:all); use strict; print header; print "Directory to search: "; my $dir=; chomp $dir; my $dir="/home/lender/nameofdirectory/blankpage"; my($file); 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=)){ $a=~ s/blankpage/newsite/; print DEST $a; } close(DEST); close(F); } closedir(DH); From jtillman at bigfoot.com Sun Jan 19 19:26:55 2003 From: jtillman at bigfoot.com (James Tillman) Date: Mon Aug 2 21:37:57 2004 Subject: [Tallahassee-pm] (No subject) In-Reply-To: <1042998031.webmail@bay.flrealtor.net> References: <1042998031.webmail@bay.flrealtor.net> Message-ID: <1043026016.7017.181.camel@jacob.home> On Sun, 2003-01-19 at 12:40, perl@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=; 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=)){ > $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 From perl at bay.flrealtor.net Sun Jan 19 21:03:07 2003 From: perl at bay.flrealtor.net (perl@bay.flrealtor.net) Date: Mon Aug 2 21:37:57 2004 Subject: [Tallahassee-pm] CGI Script Message-ID: <1043031787.webmail@bay.flrealtor.net> Thanks James, but no go on your ideal. 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: 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" To: Sent: Sunday, January 19, 2003 7:26 PM Subject: Re: [Tallahassee-pm] (No subject) On Sun, 2003-01-19 at 12:40, perl@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=; 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=)){ > $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 _______________________________________________ Tallahassee-pm mailing list Tallahassee-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/tallahassee-pm