Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determine owner of file.

Status
Not open for further replies.

awolff01

Programmer
Jun 17, 2003
55
US
Hello,

In perl how can I determine the owner of a file?

Better yet. I want to know if the current file I am processing is owned by the person who is running the perl script?

Is -o or -O the file tests I need to do?

Thanks.
 
The owner comes from the [tt]stat()[/tt] function, docuemtned under perlfun.

Code:
my @stat = stat($filename);
my $uid = $stat[4];

-O tells you if the script is owned by the person who logged on to run the script (real uid).

-o tells you if the script is owned by the person apparently running the script after any "su" commands, etc (effective uid).

HTH,

Yrs,


fish

"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilkes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top