How to retrieve Qshell messages using the RCVMSG and MONMSG commands in a CL program?
Resolving The Problem
You can use the RCVMSG to retrieve the QSH0005,QSH0006, and QSH0007 messages as completion messages. If the QIBM_QSH_CMD_ESCAPE_MSG environment variable is set to Y, then you can use MONMSG to monitor for these messages as escape messages.
When the command ends, STRQSH sends one of the following messages:
|o||QSH0005 is sent when the process running the command ends normally. The message includes the exit status of the process.|
|o||QSH0006 is sent when the process running the command ends by signal. The message includes the signal number.|
|o||QSH0007 is sent when the process running the command ends by exception.|
By default, the messages are sent as completion messages. You can have the messages sent as escape messages by setting the environment variable QIBM_QSH_CMD_ESCAPE_MSG. When the value of the environment variable is Y, the QSH0006 and QSH0007 messages are always sent as escape messages and the QSH0005 message is sent as an escape message if the exit status is greater than zero.
Note: After the environment variable is created and the value is set to Y, any active interactive sessions must be restarted to effect the change.
18 December 2019