CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Help with Script

 



Daniel_Leth
Deleted

Mar 17, 2000, 9:35 PM

Post #1 of 5 (502 views)
Help with Script Can't Post

Hi..

I got this script out of a CGI book but when I use it I just get a 500 error from the webserver.

Can anyone tell me how to fix it?

The script is activated using a link:

<A HREF="/cgi-bin/showstory.cgi/stories/textfile.txt">Text File</A>

#!/usr/bin/perl

print "Content-type: text/HTML", "\n\n";

print "<HTML>\n<HEAD>\n<TITLE>The Daily Misleader</TITLE>\n</HEAD>\n";
print "<BODY>\n<H1>The Daily Misleader</H1>\n<BLOCKQUOTE>\n";

$first_line =1;
$story = $ENV{'PATH_TRANSLATED'};
if (story =~ /\.\./) {
print ("<P>Paths that include .. are a security risk.</P> \n;
}
else {
if (open (INPUT, "< $story")) {
while (<INPUT> ) {
chop;
if ($first_line) {
print "<H1>", $_, "</H1>\n";
$first_line=0;
}
elsif ($_ eq "") {
print "<P>\n";
}
else {
print $_, "\n";
}
}
}
else {
print "<P>Couldn't open the requested file. </P>\n";
}
}

print "<HR WIDTH=70%>\n";
print "<P>Back to the <A HREF=\"home.html\">home page</A>.</P>\n";
print "<P>Copyright&copy; 2000, My News Service.</P>\n"



Cure
User

Mar 18, 2000, 8:28 AM

Post #2 of 5 (502 views)
Re: Help with Script [In reply to] Can't Post

Hi

The script itself will give you 500 errors because of this line.

print ("<P>Paths that include .. are a security risk.</P> \n;

needs to be:

print "<P>Paths that include .. are a security risk.</P> \n";


Cure



Daniel_Leth
Deleted

Mar 18, 2000, 5:09 PM

Post #3 of 5 (502 views)
Re: Help with Script [In reply to] Can't Post

I did as you said but I still get this:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

The Title of the page is 500 Internal Server Error


Cure
User

Mar 18, 2000, 5:42 PM

Post #4 of 5 (502 views)
Re: Help with Script [In reply to] Can't Post

Hi

The script worked for me, I activate the script from the url not the link, the link doesnt make sense

put this at the top of your script to prvent the 500 errors and see where the error is coming from

use CGI::Carp qw/fatalsToBrowser/;


Cure



darian
Deleted

Mar 20, 2000, 11:27 PM

Post #5 of 5 (502 views)
Re: Help with Script [In reply to] Can't Post

Why would you test an open statement with an if statement? I would put:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use CGI qw(:cgi);
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/HTML", "\n\n";

print "<HTML>\n<HEAD>\n<TITLE>The Daily Misleader</TITLE>\n</HEAD>\n";
print "<BODY>\n<H1>The Daily Misleader</H1>\n<BLOCKQUOTE>\n";

$first_line =1;
$story = $ENV{'PATH_TRANSLATED'};
if (story =~ /\.\./) {
print "<P>Paths that include .. are a security risk.</P> \n;
}
else {
open (INPUT, "<$story") or die("$!");
while (<INPUT> ) {
chomp;
if ($first_line) {
print "<H1>", $_, "</H1>\n";
$first_line=0;
}
elsif ($_ eq "") {
print "<P>\n";
}
else {
print $_, "\n";
}
}
}

print "<HR WIDTH=70%>\n";
print "<P>Back to the <A HREF=\"home.html\">home page</A>.</P>\n";
print "<P>Copyrightę 2000, My News Service.</P>\n";</pre><HR></BLOCKQUOTE>


[This message has been edited by darian (edited 03-21-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives