Using EXECIO

EXECIO can be used to read or write zero or more lines in a file. EXECIO differs from readfile and writefile in that it operates on open files. The file must be opened in a mode consistent with the requested read or write operation. Read operations will read from the current file cursor position. Write operations will write from the current file cursor position, or, if the file is opened for append, write operations will append to the end of the file.

To read the open file associated with file descriptor 7 into the stem called data, for example:
address mvs 'execio * diskr 7 (stem data. fini'

The data can come from and go to the stack or a stem. You can also use it to read or write an entire file. As shown in the following syntax diagram, z/OS UNIX supports all the TSO/E REXX operands except OPEN, DISKRU, and linenum.

Read syntax diagramSkip visual syntax diagramEXECIO lines*DISKW ddname(STEM var-nameFINIS)DISKR ddname(FIFOLIFOSTEM var-nameFINISSKIP)
For the ddname operand, you can use the following pseudo-ddnames for processing, when the REXX program is run from a shell or from a program:
  • File descriptors 0 to 7
  • STDIN, STDOUT, STDERR

When using EXECIO to read a file, the maximum allowable length of a line in the file is 1024 characters, including the newline character. For information about reading blocks of data, see .

Start of changeWhen using EXECIO to write to a file, there is no maximum for the amount of characters to write. One newline character is appended to the end of the written data.End of change

For information about EXECIO, see Using the EXECIO command in z/OS® TSO/E REXX User's Guide.