Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Directory created with incorrect permissions

by rspishock (Monk)
on Feb 02, 2012 at 16:58 UTC ( #951487=perlquestion: print w/replies, xml ) Need Help??
rspishock has asked for the wisdom of the Perl Monks concerning the following question:

Hello again wise monks.

One of my colleagues is encountering a strange issue with a script he's working on. His script is setting up a directory structure using the  mkdir command but the permissions are not matching the permissions that he's passing to  mkdir

This is the code that he's using:  mkdir ("$new_dir", 0770) or die $!; The directory is created, however it has 750 listed as the permissions.

I've run similar code myself and haven't noticed a problem, so I'm a bit confused. For what it's worth, the script is being run on a RedHat box.

Thanks in advance for you guidance.

Replies are listed 'Best First'.
Re: Directory created with incorrect permissions
by moritz (Cardinal) on Feb 02, 2012 at 17:10 UTC

    The mask you give to mkdir is just a mask, which is XORed with AND-ed with the negation of umask to create the actual permission bits. If the umask is 022, it's no surprise that the file comes out as 0750.

Re: Directory created with incorrect permissions
by Anonymous Monk on Feb 02, 2012 at 17:08 UTC
    Read the documentation for mkdir, it explains that umask is applied
Re: Directory created with incorrect permissions
by rustic (Monk) on Feb 02, 2012 at 17:12 UTC
    I think you almost have it in your question. Try a umask for more info.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951487]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2018-06-24 01:13 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.