Question How To Check Is File Is Writable On Unix

rzr

Member
Is there an easier / alternate way to check if user has write permission on a file?
Here's what I'm doing now. I load the ls -lrt result into cResult and parse it to check permissions.

Code:
DEFINE VARIABLE cOSCommand AS CHARACTER NO-UNDO.
DEFINE VARIABLE cResult    AS CHARACTER NO-UNDO.

cOSCommand = 'ls -lrt /home/rzr/test.txt'.
INPUT THROUGH VALUE(cOSCommand).
IMPORT UNFORMATTED cResult.
INPUT CLOSE.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
Code:
define variable v-filename as character no-undo.
/* assign a file name to the variable */
file-info:file-name = v-filename.
if index( file-info:file-type, "W" ) > 0 then
  display "file is writable".
 
Top