Changing UNIX primary group
Inyeol Lee
Inyeol_lee at yahoo.com
Wed Aug 13 11:52:40 EDT 2003
"Justin Johnson" <justinjohnson at fastmail.fm> wrote in message news:<mailman.1060697959.27558.python-list at python.org>...
> I have a unix id that has group1 for a primary group, and group2, group3,
> and group4 for supplementary groups. I'd like to change my primary group
> before running certain commands. So sometimes I might want group2 to be
> the primary group, and other times group3 or group4.
>
> I saw the posix module's setgid method, but it failed for me unless I was
> running as root. Also it only accepts the gid, but I'd rather pass in
> the group name, or somehow lookup the gid based on the name.
>
> Does anyone know a way to do all of this?
> Thanks much.
> -Justin
These are not python solution;
1) make a setgid script and put your commands there, or
2) use shell commands;
echo "command1; command2;" | newgrp group2
-Inyeol
More information about the Python-list
mailing list