[wellylug] Issues with a perl script

michael at diaspora.gen.nz michael at diaspora.gen.nz
Thu Oct 26 15:59:01 NZDT 2006


scott writes:
>On Thu, 2006-10-26 at 15:17 +1300, michael at diaspora.gen.nz wrote:
>
>> You also removed the bit that assigns the directory permissions.  A quick gu
ide:
>
>exactly- when passing the directory permissions it was either creating a
>directory called "profiles 0700" or not compiling, 

That seems odd.  There was a line in an earlier version:

    mkdir (/profiles/, 0700);

Which could possibly have had that effect.

>so I removed the
>modifiers of the mkdir command and it worked. It's been a while since I
>played with perl so I'm forgetting how to pass on those modifiers
>correctly. Doh.

The original was correct; quoting the man page:

$ perldoc -f mkdir
       mkdir FILENAME,MASK
       mkdir FILENAME
               Creates the directory specified by FILENAME, with permissions
               specified by MASK (as modified by "umask").  If it succeeds it
               returns true, otherwise it returns false and sets $!  (errno).
               If omitted, MASK defaults to 0777.

               In general, it is better to create directories with permissive
               MASK, and let the user modify that with their "umask", than it
               is to supply a restrictive MASK and give the user no way to be
               more permissive.  The exceptions to this rule are when the file
               or directory should be kept private (mail files, for instance).
               The perlfunc(1) entry on "umask" discusses the choice of MASK
               in more detail.

               Note that according to the POSIX 1003.1-1996 the FILENAME may
               have any number of trailing slashes.  Some operating and
               filesystems do not get this right, so Perl automatically
               removes all trailing slashes to keep everyone happy.

Hope that helps,

    -- michael.




More information about the wellylug mailing list