And what from perldoc -f umask is giving you problems? I mean we could look at the sample code you . . . oh, well . . . at least judging by the error message you poste. . . erm . . .
| [reply] |
A quick explanation of umask (php, but it still applies)
Jill Ramonsky Apr 2 2003
Subject: RE: PHP-WIN how to use umask() ???
The PHP manual (unfortunately) assumes some Unix knowledge here.
The paramter to umask is a bitfield, passed as an integer. Within this bitfield:
- bit 0 set implies that anyone in the world can execute the file
- bit 1 set implies that anyone in the world can write to the file
- bit 2 set implies that anyone in the world can read the file
- bit 3 set implies that anyone in the file's group (a Unix concept) can execute the file
- bit 4 set implies that anyone in the file's group (a Unix concept) can write to the file
- bit 5 set implies that anyone in the file's group (a Unix concept) can read the file
- bit 6 set implies that the owner of the file can execute the file
- bit 7 set implies that the owner of the file can write to the file
- bit 8 set implies that the owner of the file can read the file
When accessing a file, the lower 9 bits of the permissions of the file (as stored on the server) are logically ANDed with the complement of the current
"umask" - which you can set with the umask() function - and the resulting bitfield is inspected to see whether or not to grant permission for the specified action.
Jill
Jason L. Froebe
Team Sybase member No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
| [reply] |
umask gets or sets the default file permissions. With a parameter it sets the default permissions to the binary complement of the mask (octal). This is simply 777 - x where x is the argument to umask, although be aware that umask can accept four octal digits to play the same game with the higher order flags as well. So in the example of the OP, umask 022 would set the default permissions to 755. After that a mv will then by default use the permissions implied by the umask that is in effect which in the example would be 755.
| [reply] [d/l] [select] |