Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: setting file permissions through sftp

by gman (Friar)
on Feb 18, 2008 at 17:23 UTC ( [id://668616]=note: print w/replies, xml ) Need Help??


in reply to Re: setting file permissions through sftp
in thread setting file permissions through sftp

I am still not understanding the relationship between what Net::SFTP::Attributes ( 'perm' => 33092, ) and unix style file permissions? Am I missing something obvious?
  • Comment on Re^2: setting file permissions through sftp

Replies are listed 'Best First'.
Re^3: setting file permissions through sftp
by almut (Canon) on Feb 18, 2008 at 17:36 UTC

    You have to convert the value to octal representation, e.g.

    my $perm = 33092; printf "%o\n", $perm & 07777; # prints 504

    Also, to set the permissions, you probably want $attrs->perm( 0777 ), not $attrs->perm( [ '0777' ] ). The square brackets in the docs mean optional, i.e. you'd specify nothing to retrieve the value (combined 'setter' and 'getter' method...).

    Update: forgot to mention the '& 07777' above masks off the four octal groups of interest here, i.e. three times rwx (for user/group/other), plus the SUID/SGID/sticky octal group (the latter is the first (leftmost) one).

      Thank you! I would say that falls under the obvious :)

      And especially thanks for the update on the '& 07777' explanation.

      Thanks, Cory

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2025-12-14 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (94 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.