 |
The Question is:
How do I capture the output of a system command and save it in a file to be
accessed from an application. For example, how would I save the dir listing
in a file to be opened in a program that would use that information?
The Answer is :
Most OpenVMS command operations have an API equivalent.
In this case, please use the lib$find_file and related RTL calls or
use the C opendir, readdir, and related calls directly within the
application to implement the necessary directory scan, please do not
attempt to capture and parse the command output of DCL commands.
(The format of the command output can potentially change, leading
to problems with programs that attempt to parse the output.)
The C system call does not offer output redirection, but the
lib$spawn call -- the call used to implement the C system call
on OpenVMS -- does. Alternatively, various DCL-level output
redirection operations are possible, with the DCL command PIPE
as a salient example of one approach.
|