Creating directories

david wright david_v_wright at yahoo.com
Fri Sep 5 03:21:34 EDT 2008


--- On Fri, 9/5/08, srinivasan srinivas <sri_annauni at yahoo.co.in> wrote:

> From: srinivasan srinivas <sri_annauni at yahoo.co.in>
> Subject: Creating directories
> To: python-list at python.org
> Date: Friday, September 5, 2008, 1:44 AM
> Can someone tell me is there any module available to create
> directories??
> 
> I tried os, tempfile.
> I was facing some issues with os.mkdir(). The mode setting
> was not proper with this method.
> 
> I created the directory 'stdin' with '0700'
> mode using os.mkdir() method.
> $> ls -alR stdin/
> stdin/:
> total 12
> drwx--S---   2 munisams munisams 4096 Sep  3 02:00 .
> What is that 'S' in the group permission field??
> 

this appears to be working, what where you expecting? 

"An upper case "S" means there is no executable permission, but the set group id function is active- that is, a file in this directory will belong to the same group id as the directory itself."


If the parent directory has the set group id set, the child will as well.
i.e.
dwright at debian:~$ cd /tmp/
dwright at debian:/tmp$ mkdir test
dwright at debian:/tmp$ ls -ld test
drwxr-xr-x 2 dwright dwright 1024 2008-09-04 05:19 test
dwright at debian:/tmp$ ls -la test
drws------  2 dwright dwright 1024 2008-09-04 05:19 .
drwxrwxrwt 13 root    root    3072 2008-09-04 05:19 ..
dwright at debian:/tmp$ chmod 2700 test
dwright at debian:/tmp$ ls -la test
total 4
drwx--S---  2 dwright dwright 1024 2008-09-04 05:19 .
drwxrwxrwt 13 root    root    3072 2008-09-04 05:19 ..

dwright at debian:~$ python
Python 2.4.4 
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.mkdir('/tmp/test/TEST', 0700)

dwright at debian:/tmp$ ls -la test
total 5
drwx--S---  3 dwright dwright 1024 2008-09-04 05:20 .
drwxrwxrwt 13 root    root    3072 2008-09-04 05:19 ..
drwx--S---  2 dwright dwright 1024 2008-09-04 05:20 TEST

dwright at debian:/tmp$ ls -la test/TEST
total 2
drwx--S--- 2 dwright dwright 1024 2008-09-04 05:20 .
drwx--S--- 3 dwright dwright 1024 2008-09-04 05:20 ..

+David



More information about the Python-list mailing list