User and Group name => user id and group id 
Author Message
 User and Group name => user id and group id

This is kind of a trivial question, but I can't find reference for a
function that returns a numeric user id given a user name (under Linux).  I
could parse the passwd and group file, but it seems there'd be a built-in
function for it somewhere.

--
Sean O'Dell



Mon, 11 Oct 2004 01:33:04 GMT  
 User and Group name => user id and group id

Quote:

> This is kind of a trivial question, but I can't find reference for a
> function that returns a numeric user id given a user name (under Linux).
> I could parse the passwd and group file, but it seems there'd be a built-in
> function for it somewhere.

The "etc" module is standard;
it should have been built on your system.

        require 'etc'
        p Etc.getpwnam 'bin'

        #-> #<Struct::Passwd name="bin", passwd="x", uid=1, gid=1,
                gecos="bin", dir="/bin", shell="">

Documented in Ruby in a Nutshell.
Source in .../ext/etc

(OT: should the file-system stuff appear under 'Etc'?)
--
Mike Hall
http://www.enteract.com/~mghall



Mon, 11 Oct 2004 22:22:52 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to get user and group name from the IDs

2. Bay area (Northern CA) Smalltalk Users group/ Special Interest Group

3. Algol 68 users/user groups?

4. select count(*) from test_file where id>100 and id<1000

5. Retrieve the group name the user belongs to

6. LOGO-L> New York Logo Users Group

7. Automate User ID creation

8. SQL ODBC user id and password

9. Win API call, user ID, problems

10. (user ID:Bill) (Password:Gates)

11. User ID in Windows

12. User ID in Cobol Program

 

 
Powered by phpBB® Forum Software