I'd like to get the username of the owner of a file in my Ruby
program. Getting the uid is easy:
File.stat("testfile").uid -> 501
Anyone have a suggestion on how to get the actual username, like
"smith"?
I'm on Solaris without root and /etc/passwd does not list explicit
usernames.
Best,
John
Example:
require 'etc'
uid = File.stat('testfile').uid
puts 'Owner name: ', Etc.getpwuid(uid).name