Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chmod script

Status
Not open for further replies.

mrsbean

Technical User
Jul 14, 2004
203
US
I am attempting to install SugarCRM on a Linux server. To successfully install, I must set the file permissions for the modules folder and all files/subdirectories to be writable. I attempted to set the directories to 777 and the files to 755 using the following code:

Code:
<?php
system( 'find /hsphere/local/home/mrsburns/sugar.burnsidebiz.net/modules -type f | xargs 

chmod 777' );
system( 'find /hsphere/local/home/mrsburns/sugar.burnsidebiz.net/modules -type d | xargs 

chmod 777' );
?>

<h1>All Done</h1>

It ran without any error messages; however, when I checked the install process for SugarCRM, it told me that my Modules directory was still not set up right (not everything was writable). Can anyone give me guidance how to get where I need to go?

MrsBean
 
often uploading the files with authenticated ftp (for shared hosting) is the easiest way to get proper permissions.

is this on a shared host (to which you don't have shell access)?
 
I don't have shell access. There is some kind of web access to the files, but I can only apply the permissions one file or one folder at a time, and it's not recursive.

I've seen an ftp (Core FTP Professional) which claims to offer recursive settings, but I don't want to spend money if I don't have to ... If I can accomplish what I need to do without purchasing something, that seems like the best way to go.

New spin on the question: Is there a way I can pull a complete list of each file and folder under the modules directory? If I had a text file specifying each file/folder and it's exact path, I could use the plain old php chmod command and just loop throuh them.

MrsBean
 
Check out the glob() function. I think it will do what you want (for the second question).
 
when you invoke php over a web connection php typically runs with the permissions of the web-server. usually apache-user or nobody or similar for an apache-*nix combo. so using chmod or chown on the file from a web connection may not work unless sufficient privileges apply to the server process.

this is in contrast with authenticated ftp which will run with the privileges of the authenticated user.

as for ftp clients - i don't think that you need recursive functionality. just download the files and directories to your pc. delete them from the server and then re-upload them via ftp.

filezilla as an ftp client, is pretty full featured but i don't know for sure whether it supports a recursive permissions change.

alternatively, it would be a piece of cake to write an ftp utility in php to do hit each file separately. see this link for an example:

and this link for an example of how to grab a list of files recursively
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top