newbie01 perl wrote:
Hi,
Hello,
Does anyone know of any permission bit "translator"? One that can
translate the permission bit from its textual value to its octal value
and vice versa. It is alright if it is always just rwx but on a lot of
occasions nowadays, getting a lots of s, S, t, etc.
The permission bits aren't stored as text or octal but as parts of the
mode value which is an integer. If you are on Unix or Linux and have
the man pages installed you can do:
man 2 stat
from the command line which will describe details of the different
fields. You can also import the S_I* macros described in stat(2) from
the Perl modules Fcntl and POSIX.
-rwxrwxrwx 1 oracle dba 0 Mar 11 13:27 x ==> 777
-rwxr-x--- 1 oracle dba 0 Mar 11 13:27 y ==> 750
-rw-r----- 1 oracle dba 0 Mar 11 13:27 z ==> 640
The numbers 777, 750 and 640 are not octal in C, Perl and the shell,
they have to be preceded by a '0': 0777, 0750 and 0640.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/