Running Qshell commands from CL

You can run Qshell commands from the CL command environment with the Start Qshell command.

The Start QSH (STRQSH) command, also known as QSH, is a CL (control language) command that either starts a Qshell interactive session or runs a Qshell command.

If called with the CMD parameter, STRQSH runs the specified Qshell command. The possible values of the CMD parameter are as follows:

No command is provided and an interactive session is started. If CMD(*NONE) is specified and STRQSH is run in a batch job, STRQSH does nothing.
A Qshell command to run. The command can be a maximum of 5000 bytes in length. If a blank or other special characters are used, the command must be enclosed in apostrophes. If an apostrophe is intended, two apostrophes must be used.

When running a command, STRQSH starts qsh, runs the specified Qshell command, displays any output generated by the command to the C runtime terminal session, and ends qsh. Note that qsh does not run any profile files when started to run a command.

You can control what happens to the output by setting the QIBM_QSH_CMD_OUTPUT environment variable. The environment variable can have these values:

Display the output to the C runtime terminal session. This is the default value.
Throw away any output that is produced.
Store the output in the file specified by pathname. The file is truncated before output is written to the file.
Store the output in the file specified by pathname. The output is appended to end of the file.

When the command ends, STRQSH sends one of three messages:

  • QSH0005 when the process running the command ends normally. The message includes the exit status of the process.
  • QSH0006 when the process running the command ends by signal. The message includes the signal number.
  • QSH0007 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.