Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Find out username and UID/GID (http://www.velocityreviews.com/forums/t326571-find-out-username-and-uid-gid.html)

Florian Lindner 01-04-2004 03:00 PM

Find out username and UID/GID
 
Hello,
how can I find out the username and it's UID and GID on a linux system,
using the most recent python version? If possible, without the use of extra
libraries.
Thanks,
Florian


Paul Rubin 01-04-2004 03:01 PM

Re: Find out username and UID/GID
 
Florian Lindner <Florian.Lindner@xgm.de> writes:
> how can I find out the username and it's UID and GID on a linux system,
> using the most recent python version? If possible, without the use of extra
> libraries.


os.getuid(), os.getgid()

Gerrit Holl 01-04-2004 03:10 PM

Re: Find out username and UID/GID
 
Florian Lindner wrote:
> how can I find out the username and it's UID and GID on a linux system,
> using the most recent python version? If possible, without the use of extra
> libraries.


>>> import os
>>> import pwd
>>> os.getuid()

500
>>> os.getgid()

500
>>> pwd.getpwuid(500)

('gerrit', 'x', 500, 500, 'Gerrit Holl', '/home/gerrit', '/bin/bash')

I think there is a simpler way for the last one in the docs, but I'm not
entirely sure.

yours,
Gerrit.

--
188. If an artizan has undertaken to rear a child and teaches him his
craft, he can not be demanded back.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/



All times are GMT. The time now is 12:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.