UNIX for OpenVMS Users, Second Edition

Section 10.6: File Operators

10.6 File Operators

Table 10.5 lists C and Korn shell operators that test the characteristics of a file. There is no analogy to these file operators in OpenVMS, although you can use values returned by the F$FILE_ATTRIBUTES lexical function to determine the attributes of an OpenVMS file. The features returned by F$FILE_ATTRIBUTES do not translate into UNIX file operators because of the different ways in which OpenVMS and UNIX treat files. An OpenVMS file is highly structured, and F$FILE_ATTRIBUTES returns information about that structure. A UNIX file is nothing more than a string of bytes. Since a UNIX file has no file structure information, file operators only return features like file ownership and permissions.

OpenVMS

UNIX (C shell)

Form:

IF F$FILE_ATTRIBUTES(<span class="emphasis"><ifile-spec</i></span>,-<span class="emphasis"><icondition</i></span>) THEN
if (<span class="emphasis"><ifile_operator file</i></span>) then

Example:

# true if /usr/fred is a directoryif (-d /usr/fred) then

Example:

IF (F$PARSE(<span class="emphasis"><ifile-spec</i></span>).NES."") THEN
# true if /tmp/file 1 existsif (-e /tmp/file1) then

Example:

# true if /usr/fred/text is a regular fileif (-f /usr/fred/text) then

Example:

<b class="bold">$ UIC = F$USER()</b>IF (F$FILE_ATTRIBUTES("FILE",-"UIC") .EQS. UIC) THEN
% <b class="bold">whoami</b>fred# true if fred owns /usr/fred/fileif (-o /usr/fred/file) then

Example:

IF (F$FILE_ATTRIBUTES("FILE",-"PRO") .EQS.  ) THEN
# true if /usr/fred/file is readableif (-r /usr/fred/file) then

Example:

IF (F$FILE_ATTRIBUTES("FILE",-"PRO") .EQS.  ) THEN
# true if /usr/fred/file is writeableif (-w /usr/fred/file) then

Example:

IF (F$FILE_ATTRIBUTES("FILE",-"PRO") .EQS.  ) THEN
# true if /usr/fred/file is executableif (-x /usr/fred/file) then

Example:

IF (F$FILE_ATTRIBUTES("FILE",-"EOF") .EQ. 0) THEN
# true if /usr/fred/file is...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Biosensors and Microarrays
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.