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