The following table lists the redirection symbols supported by z/OS® XL C/C++ (when
not running under one of the z/OS UNIX shells)
for redirection of C standard streams from the command line or from
a system() call. 0, 1,
and 2 represent stdin, stdout, and stderr, respectively.
Table 1. z/OS XL C/C++ Redirection
symbols| Symbol |
Description |
| <fn |
associates the file specified as fn with stdin; reopens fn in
mode r. |
| 0<fn |
associates the file specified as fn with stdin; reopens fn in
mode r. |
| >fn |
associates the file specified as fn with stdout; reopens fn in
mode w. |
| 1>fn |
associates the file specified as fn with stdout; reopens fn in
mode w. |
| >>fn |
associates the file specified as fn with stdout; reopens fn in
mode a. |
| 2>fn |
associates the file specified as fn with stderr; reopens fn in
mode w. |
| 2>>fn |
associates the file specified as fn with stderr; reopens fn in
mode a. |
| 2>&1 |
associate stderr with stdout; same
file and mode. |
| 1>&2 |
associate stdout with stderr; same
file and mode. |
Notes: - If you use the NOREDIR option
on a #pragma runopts directive, or
the NOREDIR compile-time
option, you cannot redirect standard streams on the command line using
the preceding list of symbols.
- If you want to pass one of the redirection symbols as an argument,
you can enclose it in double quotation marks. For example, the following
passes the string "here are the args including a <" to prog and
redirects stdout to redir1
output a.
prog "here are args including a <" >"redir1 output a"
- TSO (batch and online) and MVS™ batch
support command line arguments. CICS and IMS™ do
not.
- When two options specifying redirection conflict with each other,
or when you redirect a standard stream more than once, the redirection
fails. If you do the latter, you will get an abend. For example, if
you specify
2>&1
z/OS XL C/C++ uses
the first redirection and ignores any subsequent ones. If you specify
>a.out
the
redirection fails and the program abends.
- A failed attempt to redirect a standard stream causes your program
to fail in initialization.
- The C standard streams can be redirected to large format sequential
data sets. If this occurs, the stream will be reopened without repositioning
(noseek). In this situation, the reopen is initially attempted with
repositioning (seek), fails with an ABEND 213-14 or 213-16, and the
stream is then reopened without repositioning.