我在solaris5-10上使用python2.6.4。在
我有一个名为“myFile”的文件。它属于其他人,属于文件组(“mygrp”)中的我(“myuser”)。下面是我的python代码。为什么它告诉我mygrp没有成员???在
>>> import os, pwd, grp
>>> stat_info = os.stat("myFile")
>>> fileUID = stat_info.st_uid
>>> fileGID = stat_info.st_gid
>>> fileGroup = grp.getgrgid(fileGID)[0]
>>> fileUser = pwd.getpwuid(fileUID)[0]
>>> print "grp.getgrgid(fileGID) = %s" % grp.getgrgid(fileGID)
grp.getgrgid(fileGID) = grp.struct_group(gr_name='mygrp', gr_passwd='', gr_gid=100, gr_mem=[])
根据the docs(重点我):
这也许可以解释为什么你没有被列入结果,即使你是这个小组的一员。{a2和组的其他成员必须使用它。在
更新:根据评论中的link进一步解释:
检索组的所有成员的示例代码:
相关问题 更多 >
编程相关推荐