We know that we can get process or file's uid/gid in python. For
example:
$ python
>>> import os
>>> os.getuid()
1516
>>> os.getgid()
102
>>> os.geteuid()
1516
>>> os.getegid()
102
>>> os.getgroups()
[102, 600]
>>>
$ python
>>> import os,stat
>>> uid = os.stat("./file1")[stat.ST_UID]
>>> gid = os
Please see the following code.
Suppose I have many shell commands to be executed. And I don't want to
fork a sub shell for each command(eg: status,output =
commands.getstatusoutput(cmd)) because it is too expensive. I want to
use only one sub shell to execute all these commands and want to get
each