>>>>> "Zentara" == Zentara  <[EMAIL PROTECTED]> writes:

Zentara> On Wed, 20 Feb 2002 17:17:20 +0000, [EMAIL PROTECTED] (Craig Eberly) wrote:
>> Hmm, I've tried this but it doesn't seem to change the file permissions at
>> all on the backup file.  I checked into it, and my stat command or  $mode in
>> this case is equal to 33261.   Is that a normal output for the mode in the
>> stat command?  I'm on a Solaris 8 system.

Zentara> The 33261 is file permissions and file type in decimal.
Zentara> Under linux, chmod accepts this value, maybe under solaris
Zentara> you have to to have the octal value?  

Zentara> Try this instead:

Operative word there is "try", followed by an overengineered solution.

You don't need to go from number to octal-string to number on this.
Just take the number from stat, hand it to chmod.  This works
everywhere (well, at least in Unix).

For example, clearing the x-bits on a file:

    my $mode = (stat($file))[2];
    $mode &= 07777; # mask off bits that aren't the mode (always do this)
    $mode &= ~0111; # mask off the x bits
    chmod $mode, $file or die;

Or setting the x-bits:

    my $mode = (stat($file))[2];
    $mode &= 07777; # mask off bits that aren't the mode (always do this)
    $mode |= 0111; # set the x-bits
    chmod $mode, $file or die;

No conversion to or from "octal" required.  It's a number already.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to