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

how can I check too see if a direcotry is CHMOD to 755 or 777

Replies are listed 'Best First'.
(wil) Re: checking CHMOD on directories
by wil (Priest) on Jun 29, 2002 at 11:27 UTC
    japhy, a fellow saint has written a funky module called File::chmod which might be worth looking at.

    You will be specifically interested in the function getchmod() which does exactly what it 'says on the box' - i.e. returns a list of the current mode of each file you pass to it. You might also be interested in the functions that returns symbolic permisson modes and only "ls" permisson modes.

    Hope this helps.

    - wil
Re: checking CHMOD on directories
by Zaxo (Archbishop) on Jun 29, 2002 at 08:11 UTC
    my $mode = 03777 & (stat "/path/to/")[2];

    Mode '777' is 511, '755' is 493, sticky 777 (like /tmp) is 705. The modes are commonly cited as octal numbers, as is the mask in the code.

    It may be preferable to use -w "/path/to/" or similar as a test of permissions.

    After Compline,
    Zaxo

Re: checking CHMOD on directories
by joshua (Pilgrim) on Jun 29, 2002 at 04:34 UTC
    I'm not sure how you're wanting to use this info in your script, but you may want to check out this.

    Joshua