Jump to content

[Answered] Unable To Access Cgi-Bin


Boldkyky

Recommended Posts

Hello,

 

 

I've been trying to access my cgi-bin but I'm getting the following message:

 

Forbidden

 

You don't have permission to access /cgi-bin/ on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

So far I've tried the suggestion made by xaav in this thread. I've tried all types of Indexing options in the Index manager but none seem to allow me access to the bin.

 

I'm trying to try out my very first perl script and from what I've read it needs to be uploaded directly into this bin.

 

Thanks for any input you may offer.

Link to comment
Share on other sites

cgi-bin index is automatically set to forbidden, why not go to the file directly?

 

I've tried that as well and I'm getting an error. Since this is my first time programming in Perl I'm not sure if the error is due to my code or the fact that cgi-bin access is forbidden.

Link to comment
Share on other sites

If it was a code error, you would most likely get a 500 Internal Server Error. Could you post a link to your script?

 

That's actually the error I'm getting.

 

http://edam.heliohost.org/cgi-bin/takesurvey.pl

 

I'll have to take a look at the code then :). Speaking in theory terms, would a user be able to access a direct link to something stored within the cgi-bin, even if the cgi-bin itself gives the 400 error?

Link to comment
Share on other sites

I'm completely stumped then. I've edited the file to a very simple "Hello, Perl!" script.

 

#!/usr/bin/perl

 

print "content-type: text/html \n\n"; #The header

 

print "Hello, Perl!";

 

No idea why it's not functioning.

 

I also uploaded another document into the cgi-bin and it's giving me a 500 error.

 

However, I uploaded it to the main directory and it's working fine.

Edited by Boldkyky
Link to comment
Share on other sites

Cgi can be really picky about permissions and syntax, and when it isn't exactly perfectly right it throws the very unhelpful 500 error.

 

Step one on troubleshooting is to make sure your cgi-bin directory and cgi file both have 755 permissions.

 

Step two is to make sure you're using the right shebang, which according to your code above looks right to me.

 

Step three is to make sure you set the correct content type.

print "Content-type:text/html\r\n\r\n";

Is what I use for perl cgi and it works on Heliohost. There may be other slight variations that work too.

 

Let us know if that doesn't fix the problem.

Alright, the next thing I would check would be the encoding on the file. Make sure it's not some crazy dos format with ^M's everywhere, or any other weird line endings. Like I said above cgi can be really picky about syntax, and line endings is just another tough to troubleshoot part of it.

  • Like 1
Link to comment
Share on other sites

Thanks so much for the help offered so far. I have actually set the permissions to 7-5-5 on the file, I have no idea how exactly to do that on the cgi-bin itself.

 

The file itself seems to be uploading correctly. I'm writing it in notepad but still checking it using the code editor Heliohost offers since I read that sometimes additional characters cause issue.

 

Edit: Nevermind, found where to change the permissions for the cgi-bin. Still getting the same error.

Link to comment
Share on other sites

I have actually set the permissions to 7-5-5 on the file, I have no idea how exactly to do that on the cgi-bin itself.

It has 755 permissions when your account is created unless you've changed it.

The file itself seems to be uploading correctly. I'm writing it in notepad but still checking it using the code editor Heliohost offers since I read that sometimes additional characters cause issue.

Windows notepad generally saves files with DOS line endings which would cause 500 errors.

Link to comment
Share on other sites

Apparently I somehow had managed to change the cgi-bin permits, even though I don't recall doing such a thing.

 

You were right about the DOS line endings with Notepad, I created a new file directly with Heliohost's editor transcribed the code and voila! Issue resolved.

 

I do have another question if you don't mind my constant asking. I uploaded the file survey.html into both the cgi-bin and the main directory. The main directory one functions perfectly but the cgi-bin one is still giving me errors. Here are the links:

cgi-bin: http://edam.heliohost.org/cgi-bin/survey.html

main directory: http://edam.heliohost.org/survey.html

 

I'm wondering what the error could be. The files are identical, both typed in notepad but the MD one works perfectly while the other one doesn't. I figure if it was notepad giving issues, wouldn't the two of them reflect the same error?

Link to comment
Share on other sites

I do have another question if you don't mind my constant asking. I uploaded the file survey.html into both the cgi-bin and the main directory. The main directory one functions perfectly but the cgi-bin one is still giving me errors. Here are the links:

cgi-bin: http://edam.heliohost.org/cgi-bin/survey.html

main directory: http://edam.heliohost.org/survey.html

 

I'm wondering what the error could be. The files are identical, both typed in notepad but the MD one works perfectly while the other one doesn't. I figure if it was notepad giving issues, wouldn't the two of them reflect the same error?

Html files won't work right in cgi-bin because cgi-bin is only for executables and when an html file is executed it's going to result in a 500 error.

 

However, if you create a file named survey.html and give it the contents:

#!/usr/bin/perl

print "Content-type:text/html\r\n\r\n";
print '<html>';
print '<head>';
print '<title>Survey</title>';
print '</head>';
print '<body>';
print 'This is a survey...';
print '</body>';
print '</html>';

It will work.

Link to comment
Share on other sites

However, if you create a file named survey.html and give it the contents:
 #!/usr/bin/perl print "Content-type:text/html\r\n\r\n"; print ''; print ''; print ''; print ''; print ''; print 'This is a survey...'; print ''; print ''; 

It will work.

 

What I'm attempting to do is create a takesurvey.pl page that will read the HTML file. Unless I'm horribly mistaken, which so far I seem to have made every single textbook mistake out there, it should be something similar to what is explained on this tutorial: http://www.tizag.com/perlT/perlfileopen.php

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...