Running MQSC commands from text files
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.
stdin
from a text file, first create a text file containing the MQSC
commands using your usual text editor, and then run the runmqsc command.
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.
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 1 shows an extract from the MQSC command file myprog.in
and Figure 2 shows the corresponding extract of the output in myprog.out
.
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 command files
For portability among IBM® MQ environments, limit the line length in MQSC command files to 72 characters. The plus sign indicates that the command is continued on the next line.
MQSC command reports
stdout
. The report contains:- A header identifying MQSC commands as the source of the report:
WhereStarting MQSC for queue manager jupiter.queue.manager.
jupiter.queue.manager
is the name of the queue manager. - An optional numbered listing of the MQSC commands issued. By default, the text of the input is echoed to the output. Within this output, each command is prefixed by a sequence number, as shown in Figure 2. However, you can use the -e flag on the runmqsc command to suppress the output.
- A syntax error message for any commands found to be in error.
- An operator message indicating the outcome of running each command. For example, the operator
message for the successful completion of a DEFINE QLOCAL command is:
AMQ8006: IBM MQ queue created.
- Other messages resulting from general errors when running the script file.
- A brief statistical summary of the report indicating the number of commands read, the number of
commands with syntax errors, and the number of commands that could not be processed. Note: The queue manager attempts to process only those commands that have no syntax errors.
Running the supplied MQSC command files
- amqscos0.tst
- Definitions of objects used by sample programs.
- amqscic0.tst
- Definitions of queues for CICS® transactions.
In IBM MQ for Windows, these files are
located in the directory
. MQ_INSTALLATION_PATH
\tools\mqsc\samplesMQ_INSTALLATION_PATH
represents the high-level directory in which
IBM MQ is installed.
On UNIX and Linux® systems these
files are located in the directory
. MQ_INSTALLATION_PATH
/sampMQ_INSTALLATION_PATH
represents the high-level directory in which
IBM MQ is installed.
The command that runs them is:
runmqsc < amqscos0.tst >test.out
Using runmqsc to verify commands
runmqsc -v < myprog.in > myprog.out
- Running a large number of commands from a command file.
- Using an MQSC command file many times over.
The returned report is similar to that shown in Figure 2.
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 IBM MQ waits for replies from the remote queue manager.