IBM PASE for i qsh, qsh_inout, and qsh_out commands

The PASE for i qsh, qsh_inout, and qsh_out commands run a QShell command. These commands use the PASE for i system command to copy PASE for i environment variables to the ILE environment and then call the QShell command program through a link in directory /usr/bin.

The PASE for i qsh, qsh_inout, and qsh_out commands all provide the syntax and behavior of the QShell qsh command, with additional support for encoding conversion of standard input and output between ASCII and EBCDIC. The PASE for i system command provides the encoding conversion support. Any other command name that links to PASE for i qsh, qsh_inout, or qsh_out (in directory /QOpenSys/usr/bin) provides the same syntax and behavior as the QShell command in directory /usr/bin with the same base name as the link.

The qsh and qsh_inout commands perform encoding conversion between ASCII and EBCDIC for standard input, standard output, and standard error. The qsh_out command performs the encoding conversion only for standard output and standard error.

To avoid unpredictable results, set the ILE environment variable QIBM_USE_DESCRIPTOR_STDIO to Y or I so that PASE for i run time and ILE C run time use descriptor standard input and output. This variable is set to Y or I by default in the IBM® i jobs that the QP2TERM program uses to run PASE for i shells and utilities.

Syntax

  qsh [command-options]

  qsh_inout [command-options]

  qsh_out [command-options]

Examples

When the QShell command does not read from standard input, you need to use the qsh_out command (instead of the qsh or qsh_inout command) to avoid unintended repositioning of the input stream. The following example uses the qsh_out command to avoid repositioning the stream that is processed by the read command, and simply echoes the contents of the file myinput to standard output.

      while read ; do
          qsh_out -c "echo $REPLY"
      done < myinput

The following example uses the QShell cat command to convert text in an IBM i source database file to the (ASCII) PASE for i CCSID and store the result in a stream file named ascii_sqlcli.h. This uses the QShell utility support for inserting line-end characters, which are not added if the PASE for i cat command is used, into the stream.

      qsh_out -c 'cat /qsys.lib/qsysinc.lib/h.file/sqlcli.mbr' > ascii_sqlcli.h

The system provides an PASE for i getjobid command that uses the symbolic link /QOpenSys/usr/bin/getjobid -> qsh_out to run the QShell getjobid command. The following example shows two ways to run the QShell utility to determine the name of the IBM i job that is running the PASE for i shell. The first method is more efficient because it avoids running the QShell interpreter. The PASE for i shell expands the variable $$ to the process identifier of the shell. The QShell getjobid command writes a line to standard output.

      getjobid $$

      qsh_out -c "/usr/bin/getjobid $$"