IBM Support

Exiting QSH after Program Is Done Running

Troubleshooting


Problem

This document provides information about how to execute a QShell command and return to CL command line when completed.

Resolving The Problem

When I run a Java program that uses the QSH command, for example:
QSH CMD('java QIBMHello')
or
QSH CMD('ls ~')
...my interactive session stays on the Qshell terminal session output screen when the command executes. How do I get my session to return to the CL command line after the QSH command is done executing?

The Qshell terminal session output screen is displayed when running the QSH command interactively in order to display the standard output and error to the client. If you do not want the standard output and error data to be display via the terminal session, you can choose to discard the output (which in turn causes the terminal session not to appear), by setting the QIBM_QSH_CMD_OUTPUT environment variable.

Run the following command to add an environmental variable:
ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(NONE) LEVEL(*JOB)
This will return the session to the CL command line (assuming that the command is issued from the CL command line). When the interactive job is ended, the environment variable is unset.

If you would like to set the variable system-wide for all jobs, run the following command to add a system environment variable:
ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE(NONE) LEVEL(*SYS)
Next, sign off and sign back into your interactive job. Changes to the system-wide environment variable do not take effect immediately like the *JOB level environment variables. The *SYS variables are read when the job starts.
An alternate option is to use the QIBM_USE_DESCRIPTOR_STDIO environment variable.
ADDENVVAR ENVVAR(QIBM_USE_DESCRIPTOR_STDIO) VALUE('I')
 ...or:
ADDENVVAR ENVVAR(QIBM_USE_DESCRIPTOR_STDIO) VALUE('Y')
This will redirect the stdin, stdout, and stderr streams to file descriptors 0,1, and 2. 

Related Information

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHQAA2","label":"Qshell"}],"ARM Case Number":"TS011860701","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

387566758

Document Information

Modified date:
04 April 2025

UID

nas8N1015417