os.chmod() question ?

Anand B Pillai abpillai at lycos.com
Thu Apr 3 02:08:24 EST 2003


Hi pythonfolks,
 
    What numerical argument does os.chmod() accept on windoze .
For a unix box, I used to give the following for files:

chmod - 777 => All rwx permissions enabled (-rwxrwxrwx)
chmod - 644 => RW for owner, r for group/world (-rw-r--r--)

I attempted os.chmod() command on Windoze on similar lines
on a read-only file.

-r-xr-xr-x   1 DS\apillai      DS\Domain+Users       0 Apr  3 12:00 test

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chmod('test', 777)
>>> ^Z

This was the result.
-r-xr-xr-x   1 DS\apillai      DS\Domain+Users       0 Apr  3 12:00 test

Now,

Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.chmod('test', 644)
>>> ^Z

This is the result.
-rwxrwxrwx   1 DS\apillai      DS\Domain+Users       0 Apr  3 12:00 test

    Apparently, os.chmod() works differently from original chmod() command.
On a unix box, the results were totally different.

Do I need to pass an octal integer as the second argument ?

Thanks
Anand Pillai




More information about the Python-list mailing list