chmod g+ Equivalent

milan_sanremo hancock.robert at gmail.com
Mon Aug 13 19:03:45 EDT 2007


On Aug 13, 6:33 pm, ra... at dot.com (Lawrence Oluyede) wrote:
> milan_sanremo <hancock.rob... at gmail.com> 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?
>
> chmod() [1] takes as the second parameter a bitwise or-ed combination of
> a series of values. If you look at chmod's man page ("man 2 chmod" on
> the shell) you can see the following values for the group id (I have OSX
> so the actual value may be different on your OS):
>
>            #define S_IRWXG 0000070    /* RWX mask for group */
>            #define S_IRGRP 0000040    /* R for group */
>            #define S_IWGRP 0000020    /* W for group */
>            #define S_IXGRP 0000010    /* X for group */
>
> So you just have to OR them to accomplish your goal.
>
I understand that for setting the standard rwx permissions, but how do
these affect the ability to change the setgid bit?  Under Solaris you
cannot do it from the command line in absolute mode, so perhaps it is
not possible in python

I'm trying to get the equivalent of 'chmod g+' not something like
'chmod 755'.




More information about the Python-list mailing list