Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

getpwuid issue

by akrrs7 (Acolyte)
on Dec 02, 2011 at 16:09 UTC ( [id://941349]=perlquestion: print w/replies, xml ) Need Help??

akrrs7 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: getpwuid issue
by marto (Cardinal) on Dec 02, 2011 at 16:13 UTC
      The code is fairly simple - given a file - $basename
      if (-e $basename) { $attrs = stat($basename); my $fileOwnerID = $attrs->uid; $fileOwner = (getpwuid $fileOwnerID)[0]; #$fileOwner = sprintf "%s",stat($basename)->uid; my $groupID = $attrs->gid; $groupName = (getgrgid $groupID)[0]; }
      So if getpwuid is not implemented or cannot be used in Windows...how do I get the name of the owner of a file ?

        "The code is fairly simple"

        In future, as described in How do I post a question effectively? consider posting a minimal example which demonstrates the problem in your first post, rather than people having to draw information from you piece meal. I suggest you actually google search getptuid to find out what it is, and why it doesn't work on your platform.

Re: getpwuid issue
by cdarke (Prior) on Dec 02, 2011 at 18:22 UTC
    See Win32::Security::NamedObject, explicitly ownerSid.

    For background, the Win32API C is either GetFileSecurity() (get OWNER_SECURITY_INFORMATION) or GetNamedSecurityInfo(). Both with return the SID of the owner, which you have to convert to a user name.
Re: getpwuid issue
by Anonymous Monk on Dec 02, 2011 at 16:13 UTC

    But it works fine in HPUX environment. Thanks !!!

    Well, Windows XP is not HPUX, and like the message tells you The getpwuid function is unimplemented

Re: getpwuid issue
by choroba (Cardinal) on Dec 02, 2011 at 16:14 UTC
    What is the question, then? The function is implemented in HPUX, and is not implemented in MS Windows XP.
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://941349]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-18 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found