>>-access--pathname--flags-------------------------------------><
Function
access invokes the access callable service to determine if
the caller can access a file.
Parameters
- pathname
- The pathname of the file to be checked for accessibility.
- flags
- One or more numeric values that indicate the accessibility to
be tested. You can specify a numeric value (see REXX predefined variables)
or the predefined variable used to derive the appropriate numeric
value. The predefined variables you can specify are:
Variable |
Description |
---|
F_OK |
Test for file existence |
R_OK |
Test for permission to read |
W_OK |
Test for permission to write |
X_OK |
Test for permission to execute |
For example, R_OK+W_OK tests for read and write permission.
Usage notes
- Testing for file permissions is based on the real user ID (UID)
and real group ID (GID), not the effective UID or effective GID of
the calling process.
- The caller can test for the existence of a file or for access
to the file, but not both.
- In testing for permission, the caller can test for any combination
of read, write, and execute permission. If the caller is testing a
combination of permissions, a -1 is returned if any one of the
accesses is not permitted.
- If the caller has appropriate privileges, the access test is successful
even if the permission bits are off, except when testing for execute
permission. When the caller tests for execute permission, at least
one of the execute permission bits must be on for the test to be successful.
Example
To test for permission to execute
grep:
"access '/bin/grep'" x_ok