CONSOLE – Issue z/OS console commands

Use the CONSOLE command to issue commands to the z/OS console.

CONSOLE <command>

Where <command> can be any valid REXX expression that resolves to a valid console command. For more details about REXX expressions and available functions, see TSO/E REXX Reference manual.

Subscripted variables can be used to issue a series of commands in a loop. For example, to issue a set of commands 10 seconds apart:
VARSUB SCAN (!)
VARSET CMD1 = "F WSIC,STATUS" 
VARSET CMD2 = "F WSJC,STATUS" 
VARSET CMD3 = "F WSKC,STATUS" 
VARSET CMD4 = "F WSLC,STATUS" 
DO X = 1 TO 4 
   CONSOLE @V(CMD!X) 
   WAIT 10 
END
The commands could be contained within a file and read into the process:
//RUNWAPL  EXEC EQQYXJPX, 
//         SUBSYS=WSLC 
//COMMANDS DD * 
F WSIC,STATUS 
F WSJC,STATUS 
F WSKC,STATUS 
F WSLC,STATUS 
//SYSIN    DD * 
VARSUB SCAN (!)
READ COMMANDS OBJECT(CMDS) 
DO X = 1 TO !@CMDS 
   CONSOLE @V(@CMDS-!X.) 
END

To run the commands, ensure the you have the appropriate MCS console authority.

By default the console name will be the same as the job name. This can be altered by OPTIONS CONNAME.

After the command is issued, the process waits 2 seconds for the first messages to be issued, then waits up to 1 second for each subsequent message to be displayed. After one second passed with no new messages, the CONSOLE command completes. This can be altered by OPTIONS CONWAIT.

IEExxx messages returned from issuing console commands are typically informational (suffix I) and indicate a failure. To ensure the errors are not missed, all IEExxxI messages are considered as errors (suffix E). By setting OPTIONS CONINFO, the IEExxxI messages are considered as informational messages. By setting OPTIONS CONWARN, the IEExxxI messages are considered as warning messages. To verify the current settings of these OPTIONS commands, issue SHOW OPTIONS.

Any other messages retrieved will set return codes according to the message severity:

  • I and A return 0
  • W returns 4
  • Anything else returns 8