Re: "not enough arguments" with 'mkdir' command
by Roger (Parson) on Dec 09, 2003 at 00:57 UTC
|
You could type perldoc -f mkdir from the command prompt to get the documentation for the 'mkdir' function. And I would also check for the return status of mkdir to see if it has succeeded or not.
Another point is that file masks are octal numbers, so that
mkdir 'dir', 700; # incorrect
is not the samething as
mkdir 'dir', 0700; # correct
Having said that, you can certainly overcome this problem by a subsequent call to 'chmod' -
chmod 'dir', 0700;
| [reply] [d/l] [select] |
|
OK, after looking at the perldoc, it says nothing about the mask being optional. You are correct. Thanks for this. I was also supplying the mask as a string literal, not an integer.
| [reply] |
•Re: "not enough arguments" with 'mkdir' command
by merlyn (Sage) on Dec 09, 2003 at 11:15 UTC
|
I see a lot of responses talking about this argument as the "mask" argument. That's the "mode" argument, or "permission mode" to be a little more verbose.
Perhaps the confusion is that the bits of the "umask" are cleared out of this value, per normal Unix policy on creating new files and directories. If it was a "mask", what is it masking? {grin}
And yes, this was mandatory in Perl 2 through Perl 5.5, and became optional in Perl 5.6.
| [reply] |
|
mkdir FILENAME,MASK
mkdir FILENAME
Note: in 5.005, it was called mode.
| [reply] [d/l] |
|
Ugh. I wonder who broke the docs then. Ugh. Time to file a bug report.
| [reply] |
Re: "not enough arguments" with 'mkdir' command
by jsprat (Curate) on Dec 09, 2003 at 01:01 UTC
|
When I try to supply a mask argument to the above, the directory gets created but not with the mask I used.
When you say "but not with the mask I used", what exactly do you mean? Do you supply '0777', but it is created '0755'?
What is the mask you are supplying, what are the permissions on the directory, what are you expecting the new directory's permissions to be - and finally, what is your umask?
| [reply] |
|
OK, I was supplying the mask as a string literal, surrounded by single quotes, which gave me interesting results. When I supply an integer in octal, the correct permissions are set. Thanks for the help.
| [reply] |
Re: "not enough arguments" with 'mkdir' command
by duff (Parson) on Dec 09, 2003 at 00:38 UTC
|
Not enough clues have been given, but I can guess that it didn't use the mask you thought you specified because you used the wrong format. e.g., 777 instead of 0777. As to why mkdir complains about the number of arguments ... are you sure that's a perl error?
| [reply] [d/l] [select] |
|
mask was required in 5.005_03. It became an optional argument for mkdir in 5.6, iirc.
| [reply] [d/l] |
|
are you sure that's a perl error?
The mask argument is optional and defaults to 0777. He should be able to get by with a single argument. I agree with you that he didn't provide enough clues.
Update: Oops, jsprat++ is completely correct. The mask is not optional in 5.005. Sorry for any confusion.
-sauoq
"My two cents aren't worth a dime.";
| [reply] |
|
I tried both 777 and 0777. But I get the error when I don't supply the mask. Here's the entire error message:
Not enough arguments for mkdir at ./test_file.pl line 3, near "'ding';
+"
Execution of ./test_file.pl aborted due to compilation errors.
The entire program is just one line.
| [reply] [d/l] |
|
perl -e "mkdir q(foobar), 0777"
work for you?
Update: Changed to include umask as jsprat's comment is correct.
-sauoq
"My two cents aren't worth a dime.";
| [reply] [d/l] |
|