Get Owner of a file

C

Charles Heizer

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
 
F

Farrel Lifson

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 Lifson

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

Marcelo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top