in reply to Confusion opening a file

Just two things:

Most likely the file permissions do not allow the script to open the file. Remember that you might have more permissions than the script has, if the script is not running as you.

Replies are listed 'Best First'.
Re: Re: Confusion opening a file
by hmerrill (Friar) on Oct 01, 2003 at 16:29 UTC
    My Apache runs as user "nobody", so whatever user your Apache runs as will need "r"ead access to the file you're trying to open. I'M NOT CERTAIN about this, but I think that if you want to grant the webserver(cgi script) read access to a file, and the absolute path to the file is
    /path/to/read_file.html
    then
    directory 'path' needs to grant read and execute privs to the webserver user, and directory 'to' needs to grant read and execute privs to the webserver user, and file read_file.html needs to grant read privs to the webserver user.
    I think(?) the directories need to grant 'execute' privs to enable descending into those directories. On my system I tried this with 'root' owner and 'root' group owning all files and directorys under /path - so to allow webserver user "nobody" to be able to read /path/to/read_file.html, I had to do
    chmod o+rx /path chmod o+rx /path/to chmod o+r /path/to/read_file.html
    HTH.
Re: Re: Confusion opening a file
by Hammy (Scribe) on Oct 01, 2003 at 18:45 UTC
    Thanks for the advice. Through a lot of trial and error I found a solution. I was trying to open the file with a relative address, but the official domain is not yet pointing to the machine (so it could not find it). When I use $ENV{DOCUMENT_ROOT} it finds the file (my problem is it was not finding it - I was reading an old log file that said the error was permission related. As you can tell, I am not real strong with administration issues, but I am getting there.