RAA - etc

etc / 0.0.1

Short description: read-only interface to /etc/passwd, /etc/group
Category: Library/System
Status: stable
Created: 2003-08-05 21:59:04 GMT
Last update: -
Owner: ahoward (Projects of this owner)
Homepage: http://www.codeforpeople.com/lib/ruby/etc/
Download: http://www.codeforpeople.com/lib/ruby/etc/
License: Ruby's
Dependency:
None
Description:

# example of ETC::PASSWD usage
puts 'ETC::PASSWD'
puts '---'

ETC::PASSWD.each_with_index do |entry, i|
puts entry
break if i > 5
end
puts '---'

r = rand ETC::PASSWD.size
user = ETC::PASSWD.entries[r]

puts "USER #{user} CHOSEN AT RANDOM"
puts '---'

name = user.name
uid = user.uid

printf "ETC::PASSWD[%s] -> [%s]\n", name, ETC::PASSWD[name]
puts '---'

printf "ETC::PASSWD[%d] -> [%s]\n", uid, ETC::PASSWD[uid]
puts '---'

puts ETC::PASSWD.max
puts '---'

puts ETC::PASSWD.min
puts '---'

puts 'ETC::GROUP'
puts '---'

# example of ETC::GROUP usage
ETC::GROUP.each_with_index do |entry, i|
puts entry
break if i > 5
end
puts '---'

r = rand ETC::GROUP.size
group = ETC::GROUP.entries[r]

puts "GROUP #{group} CHOSEN AT RANDOM"
puts '---'

name = group.name
gid = group.gid

printf "ETC::GROUP[%s] -> [%s]\n", name, ETC::GROUP[name]
puts '---'

printf "ETC::GROUP[%d] -> [%s]\n", gid, ETC::GROUP[gid]
puts '---'

puts ETC::GROUP.max
puts '---'

puts ETC::GROUP.min
puts '---'

Edit this project (for project owner)

back to RAA top