Understanding CHMOD

Fuzzyman michael at foord.net
Fri Feb 13 10:56:35 EST 2004


Tim Daneliuk <tundra at tundraware.com> wrote in message news:<bfhuf1-b0u.ln1 at eskimo.tundraware.com>...
> Fuzzyman wrote:
> 
> > Ok.... so I might be a windoze user trying to program CGIs for a Linux
> > server.... but Python doesn't seem to go out of it's way to make
> > understanding file attributes difficult. The python manual is
> > appalling in this are a :-(
> 
> These are Unix-style permissions and the right place to
> get more info would be a Unix OS man page for 'chmod'.
> 
> As it happens, last year, I wrote a Python program that
> examines file attributes portably across Win32 and Unix.
> You can have a look at the code that does this (among many
> other things) at:
> 
> http://www.tundraware.com/Software/twander/

Thanks very much.
I'll have a look - much appreciated.

Fuzzy

http://www.voidspace.org.uk/atlantibots/pyhtonutils.html

> 
> 
> > 
> > Anyway - I think I've finally worked out that the correct way to get
> > (rather than set) the mode of a file is :
> > 
> > from stat import *
> > S_IMODE(os.stat(filepath)[ST_MODE])
> > 
> > Obvious huh !
> > 
> > The result will be some bitmasked combination of the following ?
> > 
> > statlist = [S_ISUID, S_ISGID, S_ENFMT, S_ISVTX, S_IREAD, S_IWRITE,
> > S_IEXEC, S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, S_IRWXG,
> >  S_IRGRP, S_IWGRP, S_IXGRP, S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH]
> > 
> > Which mean ??????
> > 
> > Having obtained a result from S_IMODE(os.stat(filepath)[ST_MODE]), how
> > do I work out what it means ?
> > 
> > Thanks.
> > 
> > Fuzzy
> > 
> > http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list