bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getpwnam


From: Andreas Schwab
Subject: Re: getpwnam
Date: Thu, 01 Jan 2004 21:10:15 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (gnu/linux)

Bruce Korb <address@hidden> writes:

> Hi Andreas,
>
> Andreas Schwab wrote:
>> >>   getent passwd bob
>> >>   bob:x:1000:1000:Bob Proulx,,,:/home/bob:/bin/bash
>> >
>> > 1.  you cannot get it by user id,
>> 
>> Yes, you can.
>
> OK.  I only read the man/info pages.

getent uses the same interfaces as getpwnam, getpwuid, etc.

>> > 2.  you must still know that the comment is the 5th field, for example
>> >     and parse the line.  Thus, getent isn't any better than:
>> >        egrep '^bob:' /etc/passwd
>> 
>> Of course it is, think of NIS, LDAP, etc.
>
> OK.  It still isn't much fun working awk-ward scripts and having to remember
> how many colons you gotta skip over.  This is too much easier:
>
> $ getpwnam -A
> bkorb x 500 dev 501 Bruce Korb /home/bkorb /bin/ksh
> $ getpwnam -VA
> user name:    bkorb
> password:     'x' (encrypted)
> user id:      500
> group name:   dev
> group id:     501
> full name:    Bruce Korb
> directory:    /home/bkorb
> login shell:  /bin/ksh

The output of getent is much easier to parse than both of your examples.
The first form is ambigous, and in the second form the tag names likely
change due to i18n.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]