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

hi i have created a directory , say dir1_temp using following command in perl script mkdir("dir1_temp",0777) it is working fine in linux platform but not in cygwin . it is creating the directory but does not allows to write any thing .can any one tell how to solve this so that when i create directory it automatically gice permissions to write to it . i want every thing in perl script only. thanx sachinc

Replies are listed 'Best First'.
Re: need help in directory creation
by PodMaster (Abbot) on Feb 01, 2005 at 09:34 UTC
    How did you learn about mkdir? By reading perlfunc right? If you read closely you'll notice what I've hilighted
    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...

    So what are you gonna do next?

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: need help in directory creation
by jkva (Chaplain) on Feb 01, 2005 at 13:13 UTC
    From what I know, in certain occasions (from own experience) cygwin will have problems assigning a umask, so be careful of that.

    Good luck,

    Detonite
Re: need help in directory creation
by radiantmatrix (Parson) on Feb 01, 2005 at 14:24 UTC

    You may have to live with a two-step directory creation process. Check out File::chmod -- it will set file permissions, but does not use the same internals as the Perl mkdir() call.

    That said, Cygwin can be an interesting bucket sometimes -- how things work often depend largely on how your Cygwin is built and configured. The File::chmod module works under ActiveState Perl, however, so that might be your solution to running your script under Windows.

    radiantmatrix
    require General::Disclaimer;
    s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}