(jjhorner) First Script
by jjhorner (Hermit) on Jul 17, 2000 at 21:26 UTC
|
J. J. Horner
Linux, Perl, Apache, Stronghold, Unix
jhorner@knoxlug.org http://www.knoxlug.org/
| [reply] [Watch: Dir/Any] |
|
jjhorner made some great points above. I think he likely hit it on the head with respect to the ExecCGI option in your httpd.conf file. Go to www.apache.org to read up on documentation on this config file.
Your other temporary fix (assuming your current httpd.conf allows it) is to override the global access directives with your own .htaccess file in the same dir as your script with a single line that says
Options ExecCGI
But this will only fix it for that directory, like I said. You'll also want to make sure your httpd.conf contains a handler for the .cgi and .pl scripts. :-)
| [reply] [Watch: Dir/Any] [d/l] |
Re: First Script
by maverick (Curate) on Jul 17, 2000 at 21:20 UTC
|
this looks like a permission problem.
things to check:
- you have the correct path the perl
- the script is executable. chmod 755 my_script.pl
- the script is in a directory that is accessable by the web server
- the script is in a directory that is setup as a CGI
directory by the web server.
Try running the script from the command line. If it runs,
then the problem is most likely in the web server's configuration.
/\/\averick
| [reply] [Watch: Dir/Any] |
RE: First Script (Ozymandias: File permissions)
by Ozymandias (Hermit) on Jul 17, 2000 at 21:17 UTC
|
Permissions error. Make sure the webserver has permission to execute the script.
For a simple script like this, just give everyone read/execute permissions. Keep in mind that CGI security is normally very complex, and you're going to want to be much more careful normally. But for now (assuming Unix/Linux) just execute this as the owner of the script:
chmod 755 <filename>
- email Ozymandias
| [reply] [Watch: Dir/Any] [d/l] |
Re: First Script
by btrott (Parson) on Jul 17, 2000 at 21:27 UTC
|
| [reply] [Watch: Dir/Any] |
Re: First Script
by mrmick (Curate) on Jul 17, 2000 at 23:13 UTC
|
Even though this is not a Perl-specific response, here is
a list of http ErrorDocument types:
Where type is one of:
- 302 - REDIRECT
- 400 - BAD_REQUEST
- 401 - AUTH_REQUIRED
- 403 - FORBIDDEN
- 404 - NOT_FOUND
- 500 - SERVER_ERROR
- 501 - NOT_IMPLEMENTED
Incidentally, I tried your code and it works fine. If you
uploaded the file from a PC, you may want to check for
control M's. This has caught me in the past (before I
learned vi). You will see the following in your file if this is the case:
^M
Mick | [reply] [Watch: Dir/Any] [d/l] |
|
Mick, did you run the code yourself (if so, could you explain how) or did you run it off my website?
Thanks
| [reply] [Watch: Dir/Any] |
|
Well, if you are able, run the script from the command line. If your program fails to compile, that may be the problem.
Quick checklist:
- Correct permissions.
- Correct shebang line
- In the correct directory?
- Is a particular extension required (i.e., do you have myprog.pl instead of myprog.cgi)?
Another thing to do (in test only, don't use this for production), is to add the following line to the script:
use CGI::Carp qw(fatalsToBrowser);
If your script actually gets as far as compiling and the program tries to run, this will output the error messages to your browser, which aids debugging. Make sure that you take this out when you move the code to production as there is no sense in giving hackers additional information.
From what you are describing, it sounds like the problem is not with your code, but with the configuration. You have your code in the wrong place or something.
Is there any chance that you made corrections to your code that you forgot to upload to the server? | [reply] [Watch: Dir/Any] [d/l] |
|
|
|
I ran it (without any modifications) on my intranet webserver. It's an HP-UX running Netscape Suitespot server, if that helps. :-)
Mick
| [reply] [Watch: Dir/Any] |
RE: First Script
by wardk (Deacon) on Jul 18, 2000 at 02:03 UTC
|
make sure the file has proper permissions for reading and executing.
chmod 755 <filename>
should make it executable and restrict only you from editing.
| [reply] [Watch: Dir/Any] |
RE: First Script
by Smash8 (Initiate) on Jul 17, 2000 at 21:47 UTC
|
I'm really sorry to keep pestering everyone with my simple
problem, but this is my first time every trying to get a
script to work. Everyone posted a lot of helpful information
for someone with a vague idea of perl, but as I said, I am
very new. I think the problem is definately in the access
privliges, which seems to be chmod (????). How do I implement
chmod to change access? Or is it just a problem my hosting
service needs to take care of? Thanks a lot | [reply] [Watch: Dir/Any] |
|
Your provider might have to do it.
If you can log in using a shell account, do so. Go to the directory where the script is located, and execute the command (assuming the filename is script.pl)
chmod 755 script.pl
And that's all you have to do. If you can't do that, then your provider will have to explain how to do it.
Also, make sure your script is in the CGI directory for the site. Your provider will tell you where that is.
- Ozymandias
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] |
|
You have to have telnet access to the box that houses your script. You simply telnet there and run chmod 755 <filename>.
Apterigo
| [reply] [Watch: Dir/Any] |
Re: First Script
by Anonymous Monk on Jul 18, 2000 at 04:33 UTC
|
if you dont have telnet access to your site then a robust FTP program like WS_FTP or Bullet Proof FTP etc. will allow you to change permissions. | [reply] [Watch: Dir/Any] |
Re: First Script
by frankus (Priest) on Jul 18, 2000 at 18:22 UTC
|
Blimey, my first script was :
print "Hello World.\n";
Brother Frankus. | [reply] [Watch: Dir/Any] |