Running MQSC commands interactively is suitable for quick tests, but if you have very long commands, or are using a particular sequence of commands repeatedly, consider redirecting stdin from a text file. (See Standard input and output for information about stdin and stdout.) To do this, first create a text file containing the MQSC commands using your usual text editor. When you use the runmqsc command, use the redirection operators. For example, the following command runs a sequence of commands contained in the text file myprog.in:
runmqsc < myprog.in
Similarly, you can also redirect the output to a file. A file containing the MQSC commands for input is called an MQSC command file. The output file containing replies from the queue manager is called the output file.
To redirect both stdin and stdout on the runmqsc command, use this form of the command:
runmqsc < myprog.in > myprog.out
This command invokes the MQSC commands contained in the MQSC command file myprog.in. Because we have not specified a queue manager name, the MQSC commands run against the default queue manager. The output is sent to the text file myprog.out. Figure 2 shows an extract from the MQSC command file myprog.in and Figure 3 shows the corresponding extract of the output in myprog.out.
To redirect stdin and stdout on the runmqsc command, for a queue manager (saturn.queue.manager) that is not the default, use this form of the command:
runmqsc saturn.queue.manager < myprog.in > myprog.out
MQSC commands are written in human-readable form, that is, in ASCII text. Figure 2 is an extract from an MQSC command file showing an MQSC command (DEFINE QLOCAL) with its attributes. The WebSphere MQ Script (MQSC) Command Reference contains a description of each MQSC command and its syntax.
. . . 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; . . .
For portability among WebSphere MQ environments, we recommend that you limit the line length in MQSC command files to 72 characters. The plus sign indicates that the command is continued on the next line.
The runmqsc command returns a report, which is sent to stdout. The report contains:
Starting MQSC for queue manager jupiter.queue.manager.Where jupiter.queue.manager is the name of the queue manager.
AMQ8006: WebSphere MQ queue created.
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: WebSphere MQ queue created. : . .
These MQSC command files are supplied with WebSphere MQ:
In WebSphere MQ for Windows, these files are located in the directory c:\Program Files\IBM\WebSphere MQ\tools\mqsc\samples.
On UNIX systems these files are located in the directory opt/mqm/samp (usr/mqm/samp on AIX).
The command that runs them is:
runmqsc < amqscos0.tst >test.out
You can use the runmqsc command to verify MQSC commands on a local queue manager without actually running them. To do this, set the -v flag in the runmqsc command, for example:
runmqsc -v < myprog.in > myprog.out
When you invoke runmqsc against an MQSC command file, the queue manager verifies each command and returns a report without actually running the MQSC commands. This allows you to check the syntax of the commands in your command file. This is particularly important if you are:
The returned report is similar to that shown in Figure 3.
You cannot use this method to verify MQSC commands remotely. For example, if you attempt this command:
runmqsc -w 30 -v jupiter.queue.manager < myprog.in > myprog.out
the -w flag, which you use to indicate that the queue manager is remote, is ignored, and the command is run locally in verification mode. 30 is the number of seconds that WebSphere MQ waits for replies from the remote queue manager.
Notices |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
sumqsc |