Matt Harrington <matt / msg.ucsf.edu> writes:

> i'm going through the tutorial and have in the back of my mind an idea for
> my first script.  it requires access to the unix password database along
> the lines of getpwent().  i don't see a module with this functionality in
> the library documentation.  does one exist or should i look into calling C
> from Ruby?

If you don't need shadow passwords, how about something simple such as

  def getpwent
    File.foreach("/etc/passwd") do |line|
      yield line.split(/:/)
    end
  end

  # loop over entries in password file

  getpwent do |login, pw, uid, gid, name, home, shell|
    puts "#{login} #{home}"
  end


Regards

Dave