|Keep It Simple, Stupid|
Re: any efficient way to get user's full name?by PrakashK (Pilgrim)
|on Jul 26, 2001 at 01:12 UTC||Need Help??|
This saves in $user_name whatever is in the comment field of the user's entry in the password file (assuming comments are in the sixth field).
Update: Due to the way different systems handle the comments field, the above may not work on all systems. I tested the above on Solaris 2.6 and it worked. mdillon alerted me that the name is available from the GCOS field on his system which means the index 6 should be used.
When I looked again on the Solaris system, I found that the name was available in both comment and GCOS fields. On my Linux (Debian) box it is in the GCOS field.
So, it seems that using index 6 seems to be working on both Solaris and Debian Linux systems. Here's the updated code:
Thanks to mdillon for the correction.
PS: Does anyone know the story behind the GCOS field? What does it stand for? Why do both comment and GCOS fields both exist?