Gossamer Forum
Home : General : Perl Programming :

File Permissions

Quote Reply
File Permissions
The nph-build program builds the html files properly when run from the web, but the owner is nobody and the build permissions are 644. If I want to run the script from the command line (or as a cron), the permissions that are set won't allow the script to write to the html files.

The directory permissions for the /links html directory is 777.

Is there a way to specify the file attributes while building the files?

I do not have root access to change the file permissions to allow me to write to them at the ISP where these files are located.

[This message has been edited by Johnny Hughes (edited January 23, 1999).]
Quote Reply
Re: File Permissions In reply to
Hi Johnny,

No, there is no option to specify the file permission, only the directory permission. You can experiment with the umask() function, it will set what permissions all newly created files get.

Hope that helps,

Alex
Quote Reply
Re: File Permissions In reply to
You can build a simple script to perform the chmod for you, but this opens a potential security hole on your web site, so do it with caution:

Code:
#!/usr/bin/perl

print "Content-type:text/html\n\n";
print `chmod -R 777 *`;

You can name this program something like chmod.cgi -- Place it into the top directory you wish to change and then chmod it to 755 and call the program in the web browser. It will set the permissions to 777 for all files in the tree. If you only want to do files in that directory, remove the "-R", or change the wildcard "*" as needed.

I VERY STRONGLY SUGGEST YOU REMOVE THIS FILE ONCE DONE USING IT FROM THE SERVER, OR RENAME IT SO THAT IT CANNOT BE EXECUTED!! Also, by chmod'ing to 777, I assume you're doing this to either write over the files from the prompt and/or delete them. It is not a very good idea to have alot of writable HTML files on the server. If you chmod to 777, make sure you chmod back to 644 later to keep your stuff secure.


------------------
Fred Hirsch
Web Consultant & Programmer