OSF DCE Administration Guide--Core Components

OSF DCE Administration Guide—Core Components
file5
dcecp>
The open command assigns a file identifier to each file when it is opened. Use the file
identifier to refer to files in subsequent commands.
Once a file is opened, you can add lines to a file by using the puts command. Normally,
dcecp waits until it has accumulated sufficient data before writing this information to a
file. If you want dcecp to immediately write the information to a file, use the flush
command. Use gets to read the next line from a file or use read to read a number of
bytes or all of the bytes in a file. The following example writes a list of all principals in a
file named prins:
dcecp> open prins w+
file8
dcecp> puts file8 [principal catalog]
dcecp> close file8
dcecp>
Sometimes, you don’t want to start reading or writing at the first line of a file. The DCE
control program provides several commands that set the access position so you don’t
have to advance through every line in the file. These commands will produce an error if
you use them for devices like terminals or other sequential devices that don’t support
random access. Use the seek command to set the access point in a file. Specify the
offset as a number of bytes from the origin, which can be the beginning or end of the file
or the current position. Use a negative number to move toward the beginning of the file,
as in the following example which moves back 16 bytes from the current access position.
dcecp> seek file5 -16 current
dcecp>
You can determine the current access position by using the tell command. Save the
return value in a variable so you can go back to that position in the file later on.
Finally, you can close a file by using the close command, as follows:
dcecp> close file5
dcecp>
2.16 Spawning Subprocesses
Using subprocesses to execute commands offers several convenient solutions to some
complex scripting or special administrative needs. Subprocesses can provide
Access to operating system commands
A way to establish synchronous, orderly execution
2 34 Tandem Computers Incorporated 124243