Get Owner of a file

Hello,
I’m fairly new to ruby, most of my scripting has been done in TCL and I
decided to learn a new language.

Anyways, I would like to know if there is an easay way to get the owner
of a file

For Example :
o = file.owner

Thanks

File::Stat allows you to retrieve the numeric user ID (UID) of the
owner of the file:
File.stat(“testfile”).uid
You can also get the Group ID with
File.stat(“testfile”).gid

Regards,
Farrel L.

Aimred - Ruby Development and Consulting
http://www.aimred.com

Thanks, that did the trick!

On Mon, Jul 21, 2008 at 2:36 PM, Charles H. removed_ema[email protected]
wrote:

Anyways, I would like to know if there is an easay way to get the owner
of a file

For Example :
o = file.owner

File.stat("/etc/motd").uid => 0

That should do the trick,

Marcelo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs