Obtaining user information

T

Tim Chase

Currently I can get the currently-logged-in-userid via
getpass.getuser() which would yield something like "tchase".

Is there a cross-platform way to get the full username (such as
from the GECOS field of /etc/passed or via something like
NetUserGetInfo on Win32 so I'd get "Tim Chase" instead?

Thanks,

-tkc
 
H

Hans Mulder

Currently I can get the currently-logged-in-userid via getpass.getuser()
which would yield something like "tchase".

Is there a cross-platform way to get the full username (such as from the
GECOS field of /etc/passed or via something like NetUserGetInfo on Win32
so I'd get "Tim Chase" instead?

How about:

pwd.getpwuid(os.getuid()).pw_gecos

This will give you the GECOS field of /etc/passed.
I'd assume it contains "Tim Chase" for your account.

Hope this helps,

-- HansM
 
C

Cameron Simpson

| On 10/12/11 02:44:48, Tim Chase wrote:
| >Currently I can get the currently-logged-in-userid via getpass.getuser()
| >which would yield something like "tchase".
| >
| >Is there a cross-platform way to get the full username (such as from the
| >GECOS field of /etc/passed or via something like NetUserGetInfo on Win32
| >so I'd get "Tim Chase" instead?
|
| How about:
| pwd.getpwuid(os.getuid()).pw_gecos
| This will give you the GECOS field of /etc/passed.
| I'd assume it contains "Tim Chase" for your account.

Up to a comma is the convention. Eg "Cameron Simpson, x2983".
--
Cameron Simpson <[email protected]> DoD#743
http://www.cskk.ezoshosting.com/cs/

Microsoft - where "cross platform" means "runs in both Win95 and WinNT".
- Andy Newman <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,406
Latest member
ElizabetMo

Latest Threads

Top