By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

executing newgrp from python in current shell possible?

P: n/a
Hi,
as a user on a linux system I am member of the groups "users" and
"design" with users as my default group. To controll the accessibility
of some parts of the file system, creation of files and directories in
those parts must be done with group "design". This is currently done
manually with "newgrp design" on the command line before doing
anything else. I have been looking for a way to execute this command
as a part of a script, but it seems that the changes are only valid in
the context of the script and when the script exits, the current shell
still have the original "users" group setting. It looks like the
command spawns a new command line in the context of the current xterm
as I get back to my old command line when exiting (instead of the
xterm dissapearing)

A possible alternative could be to have the python script launch a new
shell, but I still have the problem to set the group id for that new
shell (lack of python knowledge). I am happy for any advice. Maybe it
is simply not possible to do this kind of operation from a script in
python on linux.

--
kind regards,
Svenn
Jan 9 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jan 9, 5:56*am, Svenn Are Bjerkem <svenn.bjer...@googlemail.com>
wrote:
>I have been looking for a way to execute this command
as a part of a script, but it seems that the changes are only valid in
the context of the script and when the script exits, the current shell
still have the original "users" group setting.
I don't think you would want it any other way. Would you want a user
to be able to change the group and have it remain permanently? Who's
going to remember whether they were last in "A" or "B", and it opens
up oportunities for the practical joker when you go to the restroom
and leave the terminal on. Put the "change the group" code into a
separate function in a separate file (with only you as the owner) and
call it whenever you want to change groups.
Jan 9 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.