open a file
open fileName [access] [permissions]
This command opens a file and returns an identifier
that may be used in future invocations
of commands like read, puts and close.
fileName gives the name of the file to open; if it starts with
a tilde then tilde substitution is performed as described for
If the first character of fileName is ``|'' then the
remaining characters of fileName are treated as a command
pipeline to invoke, in the same style as exec.
In this case, the identifier returned by open may be used
to write to the command's input pipe or read from its output pipe.
The access argument indicates the way in which the file
(or command pipeline) is to be accessed.
It may take two forms, either a string in the form that would be
passed to the fopen library procedure, or a list of
It defaults to ``r''.
In the first form access may have any of the following values:
In the second form, access consists of a list of any of the
following flags, all of which have the standard POSIX meanings.
One of the flags must be either RDONLY, WRONLY or
Open the file for reading only; the file must already exist.
Open the file for both reading and writing; the file must
Open the file for writing only. Truncate it if it exists. If it does not
exist, create a new file.
Open the file for reading and writing. Truncate it if it exists.
If it does not exist, create a new file.
Open the file for writing only. The file must already exist, and the file
is positioned so that new data is appended to the file.
Open the file for reading and writing. If the file does not exist,
create a new empty file.
Set the initial access position to the end of the file.
If a new file is created as part of opening it,
permissions (an integer) is used to set the
permissions for the new file in conjunction with the
process's file mode creation mask. permissions
defaults to 0666.
Open the file for reading only.
Open the file for writing only.
Open the file for both reading and writing.
Set the file pointer to the end of the file prior to each write.
Create the file if it does not already exist.
If CREAT is specified and the file already exists, an error
If the file is a terminal device, prevent the file from
becoming the controlling terminal of the process.
Prevent the process from blocking while opening the file.
For details on the
O_NONBLOCK flag refer to
If the file exists, truncate it to zero length.
If a file is opened for both reading and writing then
must be invoked between a read and a write, but if for
writing or reading, then seek must be invoked before the
write or the read; (this restriction does not apply to
command pipelines opened with open). When
fileName specifies a command pipeline and a
write-only access is used, then standard output from the
pipeline is directed to the current standard output unless
overridden by the command. When fileName
specifies a command pipeline and a read-only access is
used, then standard input from the pipeline is taken from
the current standard input unless overridden by the
25 April 2004
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004