jlk has asked for the wisdom of the Perl Monks concerning the following question:
Hello everyone! I have been lurking around here for quite some time and have now decided that there is no time like the present to start learning perl. Anywho, I am working on a perl script that's only purpose at the moment, is to create a few directories and a couple of zero byte files, and change their permissions.
Below is the code that I have written so far:
#!/opt/bin/perl -w use strict; use Getopt::Long; my $clientname; my $fdgid; GetOptions ("clientname" => \$clientname, # client name for direc +tory "fdgid" => \$fdgid); # client Filedrive GID + number mkdir "/home/jlk/tmp/data/stuff/archive/$clientname",0002; mkdir "/home/jlk/tmp/data/stuff/archive/$clientname/tmp",0002; mkdir "/home/jlk/tmp/data/stuff/archive/$clientname/not_proc",0002; mkdir "/home/jlk/tmp/data/stuff/archive/$clientname/enc_arch_files",00 +02; mkdir "/home/jlk/tmp/data/stuff/archive/$clientname/enc_arch_files/inc +oming",0002; mkdir "/home/jlk/tmp/data/stuff/$fdgid/users/incoming",0002; mkdir "/home/jlk/tmp/data/stuff/$fdgid/users/incoming/$clientname",000 +2; mkdir "/home/jlk/tmp/data/stuff/$fdgid/users/outgoing",0002; mkdir "/home/jlk/tmp/data/stuff/$fdgid/users/outgoing/history",0022; system ("touch /home/jlk/tmp/data/stuff/archive/$clientname/$clientnam +e.log"); system ("touch /home/jlk/tmp/data/stuff/archive/$clientname/${clientna +me}_ack.log"); chmod 0111, '/home/jlk/tmp/data/stuff/archive/$clientname/$clientname. +log'; chmod 0111, '/home/jlk/tmp/data/stuff/archive/$clientname/${clientname +}_ack.log';
In the above code, the directories "/home/jlk/tmp/data/stuff/archive" and "/home/jlk/tmp/data/stuff/$fdgid/users" already exist. The permissions are set to 777(wide open). Also, I am running this on a Solaris 9 system running Perl v5.8.0.
When I run the script in its present state as shown above, I get the following output:
/home/jlk: ./ecgsetup.pl --clientname testing --fdgid G7778888
touch: /home/jlk/tmp/data/stuff/archive/1/1.log cannot stat
touch: /home/jlk/tmp/data/stuff/archive/1/1_ack.log cannot stat
Now, in running this script, the directory "/home/jlk/tmp/data/stuff/archive/testing" should have been created, but instead is called "/home/jlk/tmp/data/stuff/archive/1". The directory "1" has permissions d---------. Also, the directory "/home/jlk/tmp/data/stuff/users/G7778888" is not even created.
I would love to know the error of my ways, if someone could just point it out. Thank you much in advance for any and all assistance.
Regards,
jlk
Seasame street was brought to you today by the letters M, I and T and the number 3.1415926535897932384626433832795
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with script to create directories
by BrowserUk (Patriarch) on Jun 20, 2004 at 04:58 UTC | |
by jlk (Hermit) on Jun 20, 2004 at 05:09 UTC | |
by davidj (Priest) on Jun 20, 2004 at 05:34 UTC | |
|
Re: Need help with script to create directories
by Anonymous Monk on Jun 20, 2004 at 13:22 UTC | |
by jlk (Hermit) on Jun 20, 2004 at 14:35 UTC | |
by dakkar (Hermit) on Jun 21, 2004 at 08:08 UTC |