[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-AnyPerl] opening (creating) files on UNIX



You have two problems trying to open file, in a CGI-script, in a 
program that works fine on a Mac or in the shell.

1.  At cgi time, it's not "you" running the script, it's the web 
server. So, as others have pointed out, the directory into which 
you're trying to write has to have write permission for others turned 
on; or, to read a file, the directory has to have "execute" 
permission for others (so others can see its contents) and the file 
has to have "read" permission for others.

2. Since the web server running the CGI script doesn't have the same 
context information you have when you're logging in to the shell, you 
can't use simple file names.  You must use the absolute path name.

So, even though opening a file called "abc" will create a file called 
"abc" in the current directory if you run the script in the shell, 
that same script will be looking for a file called "abc" in the *web 
server's* directory when run as a cgi-script. The solution is to get 
the systems *real* absolute file name for the file and use that.

 From your login shell, do a "pwd" (print working directory) command 
in the directory containing the file you want to read or write, and 
use that as the basis of the file name.

As an example, a file called "totm.config" in one of my scripts has 
to be referred to as 
"/raid1/home2/users/m/motorcycle/cgi-bin/totm.config".

Regards,
    Richard


==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org