File.chown
takes an owner ID, a group ID (gid), and a filename. I want to use it to set a file's gid, but what I have is the group name. Is there anything in the standard library that I can use to translate a group name into a gid?
views:
44answers:
1
+3
A:
I'm not overly familiar with ruby, but the Linux syscall for this is struct group* getgrnam(const char* name)
And is obtained from the /etc/group
file.
According to this site you can find this functionality in the Etc
module:
Etc.getgrnam(‘users’) ->
#<struct Struct::Group
name="users",
passwd="x",
gid=100,
mem=["meta", "root"]>
John Ledbetter
2010-05-17 20:07:44
That's the ticket. Thanks!
Wayne Conrad
2010-05-17 20:13:38