+

Search Tips | Advanced Search

Running MQSC commands from text files

Input for the runmqsc command is taken from the standard input device, also referred to as stdin. stdin is the device from which input to the system is taken. Typically this is the keyboard, but we can specify that input is to come from a serial port or a disk file, for example.

Output for the runmqsc command is output to the standard output device, also referred to as stdout. stdout is the device to which output from the system is sent. Typically this is a display, but we can redirect output to a serial port or a file.

We might want to build the MQSC commands into a script when we use:

  • The CSQINP1, CSQINP2, and CSQINPX initialization data sets or the CSQUTIL batch utility on z/OS .
  • The STRMQM command on IBM i.
  • The runmqsc command on UNIX, Linux, and Windows.


Procedure

  1. Create a text file that contains the MQSC commands that we want to run.

    • For portability among IBM MQ environments, limit the line length in MQSC command files to 72 characters.

    • Each command must start on a new line.

    • A line starting with an asterisk (*) in the first position is ignored. This can be used to insert comments into the file.

    • Blank lines are ignored.

    • A plus sign (+) indicates that the command is continued from the first nonblank character in the next line. If we use + to continue a command, remember to leave at least one blank before the next parameter (except on z/OS where this is not necessary). Any comments or blank lines are discarded when the command is reassembled into a single string.

    • A minus sign (-), this indicates that the command is to be continued from the start of the next line. Any comments or blank lines are discarded when the command is reassembled into a single string.

    • MQSC commands that are contained within an Escape PCF (Programmable Command Format) command cannot be continued with the plus sign, or the minus sign. The entire command must be contained within a single Escape command. (For information about the PCF commands, see Introduction to Programmable Command Formats).

    • On Multiplatforms, and on z/OS for commands issued from the CSQUTIL batch utility program, we can use a semicolon character (;) to terminate a command, even if you have entered a plus sign (+) at the end of the previous line.

    • A line must not end in a keyboard control character (for example, a tab).

    • If you run the runmqsc command in client mode by redirecting stdin from a text file, IBM MQ expects the first line of the input file to be a password.

    • On Windows, if certain special characters such as the pound sign (£) and the logical NOT (¬) are used in a command script (for example, as part of an object description), they are displayed differently in the output from a command such as DISPLAY QLOCAL.

    • For information about the MQSC command syntax, see MQSC commands.

    • We can use the example MQSC command files to help you create your text file:

        amqscos0.tst
        Definitions of objects used by sample programs.

        amqscic0.tst
        Definitions of queues for CICS transactions.

      On Windows, these files are located in the directory...

        MQ_INSTALLATION_PATH\tools\mqsc\samples

      On UNIX and Linux, these files are located in the directory...

        MQ_INSTALLATION_PATH/samp

  2. Verify that the command syntax is correct on a local queue manager without running the commands. Use the -v flag on the runmqsc command.

    • From IBM MQ Version 9.2.0, use the -f option to identify the input text filename. For example:

    • For Long Term Support releases before IBM MQ Version 9.2.0, and Continuous Delivery releases before IBM MQ Version 9.1.4, use the < operator to direct the MQSC commands from the input text file to the command. For example:

    The returned report is similar to that shown in Figure 2.

    We cannot specify a remote queue manager when verifying commands. That is, we cannot specify the -w flag.

  3. When the command syntax is correct, remove the -v flag then rerun the runmqsc command.

    • From IBM MQ Version 9.2.0 run (for example) the following command:

    • For Long Term Support releases before IBM MQ Version 9.2.0, and Continuous Delivery releases before IBM MQ Version 9.1.4, use one of the following commands:

      • The < operator directs input from a text file. For example, the following command runs a sequence of commands contained in the text file myprog.in:

      • The > operator directs output to a text file. For example, the following command runs a sequence of commands contained in the text file myprog.in, and outputs it to a file called results.out:


Example

MQSC commands are written in human-readable form, that is, in ASCII text. The following example is an extract from an MQSC command file that shows an MQSC command, DEFINE QLOCAL.
Figure 1. Extract from an MQSC command file

    DEFINE QLOCAL(ORANGE.LOCAL.QUEUE) REPLACE +
    DESCR(' ') +
    PUT(ENABLED) +
    DEFPRTY(0) +
    DEFPSIST(NO) +
    GET(ENABLED) +
    MAXDEPTH(5000) +
    MAXMSGL(1024) +
    DEFSOPT(SHARED) +
    NOHARDENBO +
    USAGE(NORMAL) +
    NOTRIGGER;

When the runmqsc command completes, a report is returned. The following example is an extract from a report:

    Starting MQSC for queue manager jupiter.queue.manager.
    .
    .
    12: DEFINE QLOCAL('ORANGE.LOCAL.QUEUE') REPLACE +
    : DESCR(' ') +
    : PUT(ENABLED) +
    : DEFPRTY(0) +
    : DEFPSIST(NO) +
    : GET(ENABLED) +
    : MAXDEPTH(5000) +
    : MAXMSGL(1024) +
    : DEFSOPT(SHARED) +
    : NOHARDENBO +
    : USAGE(NORMAL) +
    : NOTRIGGER;
    AMQ8006: IBM MQ queue created.
    :
    .
    .
Parent topic: Administration using MQSC commands


Related tasks

Last updated: 2020-10-04