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

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).

Replies are listed 'Best First'.
Re^4: setting file permissions through sftp
by gman (Friar) on Feb 18, 2008 at 18:21 UTC
    Thank you! I would say that falls under the obvious :)

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

    Thanks, Cory