Dear list, I am trying to create a folder structure, say 'test/sub', and set the folder and sub folder to be writable to everyone. By default dir.create('test/sub', recursive=TRUE, mode='0777') creates folders with mode: drwxr-xr-x After Sys.chmod('test/sub',mode='0777') The folder 'test' is: drwxr-xr-x and the sub folder 'sub' is: drwxrwxrwx The question is how to generate a folder and sub folders, with every folder being drwxrwxrwx ? I am using a linux/redhat system. Thank you for your help. Xian
Linux systems have a user mask that limits the file mode creation possibilities of any processes launched from that shell. If you check your /etc/profile file, you will see the line umask 022 This prevents you by default from creating files with write access for everyone except the user. In other words, this is a linux issue, not an R issue -- the same thing happens when you use mkdir. This can be overridden, however. For example, system("chmod -R 0777 test") which recursively changes the mode of test and all its subdirectories from within R. _______________________ Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky On 05/04/2011 09:55 AM, Xian Zhang wrote:> Dear list, > > I am trying to create a folder structure, say 'test/sub', and set the > folder and sub folder to be writable to everyone. > > By default > > dir.create('test/sub', recursive=TRUE, mode='0777') > > creates folders with mode: drwxr-xr-x > > After > > Sys.chmod('test/sub',mode='0777') > > The folder 'test' is: drwxr-xr-x > and the sub folder 'sub' is: drwxrwxrwx > > The question is how to generate a folder and sub folders, with every > folder being drwxrwxrwx ? > > I am using a linux/redhat system. > > Thank you for your help. > Xian > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Please read the comments in the help about umask (and in the posting guide about the 'at a minimum' information required in postings, for the details do depend on the version of R and it seems yours is not current). In R 2.13.0: ?dir.create? creates the last element of the path, unless ?recursive = TRUE?. Trailing path separators are discarded. The mode will be modified by the ?umask? setting in the same way as for the system function ?mkdir?. so try um <- Sys.umask(0) dir.create('test/sub', recursive=TRUE) Sys.umask(um) (Whether mkdir -p respects umask depends on your OS ... and the command-line command and the system call of that name may differ.) On Wed, 4 May 2011, Xian Zhang wrote:> Dear list, > > I am trying to create a folder structure, say 'test/sub', and set the > folder and sub folder to be writable to everyone. > > By default > > dir.create('test/sub', recursive=TRUE, mode='0777') > > creates folders with mode: drwxr-xr-x > > After > > Sys.chmod('test/sub',mode='0777') > > The folder 'test' is: drwxr-xr-x > and the sub folder 'sub' is: drwxrwxrwx > > The question is how to generate a folder and sub folders, with every > folder being drwxrwxrwx ? > > I am using a linux/redhat system. > > Thank you for your help. > Xian > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595