chmod g+ Equivalent
steve at holdenweb.com
Wed Aug 15 01:30:01 CEST 2007
> On Aug 13, 8:06 pm, Steve Holden <st... at holdenweb.com> wrote:
>> milan_sanremo wrote:
>>> I've read the documentation on os.chmod() and can implement all the
>>> standard commands, but what is the syntax for the equivalent of chmod g
>>> + to set the group id?
>> I assume when you say "to set the group id" you actually mean "to assert
>> the setgid bit"? I further presume that when you say "chmod g+" you
>> actually mean "chmod g+s".
> The g+s was an omission on my part. I can see how it would confuse
> the issue.
> I'm not sure if I mean "to assert the setgid bit". My SUN docs refer
> to it being 'on'.
>> You can't have read the documentation very thoroughly. It says right at
>> the top:
> I did see this in the documentation:
> Change the mode of path to the numeric mode. mode may take one of the
> following values (as defined in the stat module) or bitwise or-ed
> combinations of them:
> * S_ISUID
> * S_ISGID
> Which refers to:
> After which it was still unclear.
> My question is in the command os.chmod(myDirectory, ?) what is the
> value for ? to turn on the setgid bit.
> Contrary to your presumption, I did read the documentation
> thoroughly. It is inability to understand the concept which prompted
> me to post the question here.
Well, you don't tell us what (if anything) you have tried so far. Python
has an interpreter that's very easy to use interactively. Why don't you try
and see if it does what you want? You can often save time by trying such
things for yourself. Though it needn't be a substitute for asking
questions on this list, it can make your questions better-informed.
In this particular case, now I understand your needs a little better,
since you want to *add* a bit setting you will likely have to use
current_permissions = os.fstat(my_directory).ST_MODE
to read the directory's current permission bits. Then you will need to
os.chmod(my_directory, current_permissions | stat.S_ISGID)
Please don't take this as gospel, though, as I am currently on the road
with only a Windows computer available, but I think it should get you
closer to where you want to be.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
More information about the Python-list