in reply to Need help with script to create directories

Hi,
As someone else noted, you need to pass strings to your input arguments, so you should use "=s" in the GetOptions hash.
Your second problem is that your first directory ("/home/jlk/tmp/data/stuff/archive/$clientname") is being created with no RWX permissions at all, even for the user. Hence no sub-directories or files can be created or of course stat'd (you can't stat what doesn't exist :) So change the mask to something more reasonable, or just leave the default (don't pass a second arg to mkdir). Finally, a work of advice- you're working too hard :-) To make a directory tree, use the mkpath function from the File::Path module, e.g.:
use File::Path; my $base_dir="/home/jlk/tmp/data/stuff/archive/$clientname"; mkpath(["$base_dir/tmp", "$base_dir/not_proc", "$base_dir/enc_arch_files/incoming" ], 0, 0755);
Does this help?
Regards,
Offer K.

Replies are listed 'Best First'.
Re^2: Need help with script to create directories
by jlk (Hermit) on Jun 20, 2004 at 14:35 UTC

    Its funny! I had asked someone else and they said that the permissions in the 'mkdir' command were the umask, not what you wanted them to be set to, but now, seeing how it has worked, it makes perfect sense.

    **a little later** Ok, I tried what was suggested and made the permissions in the mkdir commands 0775 to reflect the permissions I want and we have different results. The directories in the archive directory were created, but the permissions are not correct. The directory /home/jlk/tmp/data/stuff/archive/testing has permissions of 744 instead of 775. I am stumped as to what happened there. The directories inside of the testing directory were created and with the same permissions, 744, instead of 755. The log files were also created, but with permissions of 644 instead of 666. Am I doing something wrong with permissions?

    Regards,
    jlk

    Seasame street was brought to you today by the letters M, I and T and the number 3.1415926535897932384626433832795

      From perldoc -f mkdir:

      mkdir FILENAME,MASK
         Creates the directory specified by FILENAME, with permissions
         specified by MASK (as modified by "umask").
      

      This means that, even if you specify 0777 as MASK, the actual permissions of the directory will be 0777 & umask. You can set the umask with the function of the same name in Perl or in the shell.

      -- 
              dakkar - Mobilis in mobile
      

      Most of my code is tested...

      Perl is strongly typed, it just has very few types (Dan)