Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie question about 403 error

Status
Not open for further replies.

brayne

Programmer
Jan 18, 2005
7
AU
Hi, I'm sorry to take up your time with this question, but perhaps someone can at least point me in the right direction.

I have a fair bit of programming experience, but I have only just started looking into using Perl scripts. Unfortunately I can't seem to get to first base. I use Yahoo for my domain hosting, and they have a Perl script example available on their website for checking the current Perl version. I called the script "version.pl", and saved it into my cgi-bin folder, then tried to launch it, but got a "403 Forbidden" error. I tried with another script, and got the same result. Any clues?

Once again, I'm sorry about the extremely dumb question.

brayne
 
check your permission (chmod) on the file...should be read, write and execute.

are you directing the right path to the perl file?

just some thoughts.

- g
 
Spewn, thanks for your response. I have double-checked the permissions, and they are read, write and execute. As for the path to the perl file, I assume you are talking about the first line of the perl script that starts with the "#!". The the first line of the script is:

#!/usr/bin/perl

That's apparently correct for the Yahoo Perl setup.

As I mentioned before, the file is called "version.pl". The wierd thing is that if I try "anything.pl", I get the same 403 error, even though there is no file of that name. If however, I type in "anything.jpg" or something like that, I get a "File not Found" error. It's giving me the 403 error on anything with a ".pl" extension, regardless of whether it's there or not.

brayne
 
Hi brayne,

Try renaming your perl file with a .cgi extension. The Yahoo web server may only allow executions of files with a .cgi extension.

Regards,

LelandJ

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Hi Leland,

Thanks, but I tried that and had no success. This is a quote from the Yahoo help page:

Please make sure each script has the file extension ".pl" or if you are calling a Perl module you can use the ".pm" file extension. If your Perl script has the extension ".cgi," please rename the extension to ".pl."

I'm sure it's something I'm doing wrong, but I just don't know what.

Thanks,
brayne
 
Hi brayne,

I don't know what the problem could be, if have set sufficient permissions on the cgi-bin directory and on the target scipt, and the web server is setup to handle .pl perl scripts.

Maybe you could post the link to the script here, and have some of the perl folks on the list give it a try and see if they get the same restriction of "403 Forbidden". Sometimes this error will occur when the URL address is to the directory, rather than the file within the directory.

Regards,

LelandJ

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Hi Leland,

The script is located at:

and the script looks like this:
#!/usr/bin/perl

$command='perl -v';
$title = "Perl Version";

print "Content-type: text/html\n\n";
print "<html><head><title>$title</title></head>\n<body>\n\n";

print "<h1>$title</h1>\n";
print "<p>";
print (exec $command);

print "\n\n</body></html>";

Once again, thanks for your help.
brayne
 
Hi brayne,

The "403 Fobidden" error that the web server is retruning is not very helpful. It would be much better if we knew the real error message, which apache web server writes to its log file. Does Yahoo allow you to have access to the "error_log" file. If your sharing a web server and have your own virtual directory, the Yahoo web server might be configured to write error from your web site to your virtual directory. Check to see if you have access to the "error_log" file.

Perl can also be configured to return error messages to the browser screen. Although I don't think this will help your situation, you can use something like the following, modify for your purposes, in your scripts. Such caode as the following could be placed towards the top of each scipt.

#---------------- Begin Snip of code --------------

print qq~Content-type: text/html\n\n~;

use CGI

use CGI::Carp qw(fatalsToBrowser set_message);

sub BEGIN
{
sub handle_errors
{
my $msg = shift;

print qq
~
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html lang="en">
<head>
<title>Software - Master (TM) Shopping Cart</title>\n
</head>
<body>
<center>
<TABLE
align = "center}"
cellspacing = "0"
cellpadding = "15"
BORDER = "5"
WIDTH = "90%"
style =
"
text-align : left;
color : white;
background-color : red;
font-family : Arial, Garamond, Times New Roman, serif;
font-size : 20px;
font-style : normal;
font-weight : 100;
"
>

<tbody>

<tr>
<td align="center">
Error
</td>
</tr>
<tr>
<td VALIGN="top">

<TABLE
align = "center}"
cellspacing = "0"
cellpadding = "15"
BORDER = "0"
WIDTH = "100%"
style =
"
text-align : left;
color : black;
background-color : white;
font-family : Arial, Garamond, Times New Roman, serif;
font-size : 20px;
font-style : normal;
font-weight : 100;
"
>
<tr>
<td>

Oh gosh, got an error:<br><br>
$msg
<br>
<br>
Please notify
<a href='mailto:lelandj\@mail.smvfp.com'>Leland Jackson, CPA</a>
and let him know.
<br>
<br>

</td>
</tr>

</table>

</td>
</tr>

</tbody>
</table>
</center>
</body>
</html>
~;
}
set_message( \&handle_errors );
}

#---------- End Snip of Code --------------

Can you access the script remotely to edit it. Sometime a script has a Windows End of Line, rather than a Unix End of Line, or vice versus. This can cause a scipts to fail, so if you edit the script on the Yahoo server, make sure your editor is set to save the script with the appropriate Unix or Windows end of line.

Regards,

LelandJ





Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Leland, I do believe you've found it. I just researched the log situation, and just found this error log:

%% [Thu Mar 10 17:02:47 2005] GET /cgi-bin/version.pl HTTP/1.1
%% 403 /z/dr/brucerayne/us1/cgi-bin/version.pl
%error
Scripting not allowed

Now I need to find out why scripting is not allowed! At least I know where to go now!

Thanks again,
brayne
 
Success! And boy do I feel like an idiot.

I found out that I was on a "starter" plan, and was not eligible to use Perl scripting. In my own defense though, it wasn't easy to find this out!

I upgraded my plan, and it's all working.

Thanks again for your patience with what turned out to be a really stupid error on my part.

brayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top