Saving IBM MQ MQSC output

Technote (FAQ)


Question

How do I save the output from IBM MQ MQSC commands when running them?

Answer

IBM MQ provides a program called runmqsc to run MQSC commands, which you use to define, display, alter and delete queue manager objects, work with channels, listeners and services, display status information, administer clusters, and more. In most cases you will use runmqsc interactively, but it is possible to save the output from MQSC commands.


Running MQSC commands interactively

Normally MQSC commands are processed interactively: You type a command and runmqsc displays the results, ending when you issue the END command. Be sure to provide the queue manager name to runmqsc or it will run against the default queue manager, if you have defined one:



    Linux and UNIX

    sh> runmqsc QMGRNAME

    Windows

    C:\> runmqsc QMGRNAME

    IBM i Command Line

    ===> RUNMQSC QMGRNAME

    IBM i Qshell

    ===> /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGRNAME



When it first starts, runmqsc prints a line reading "Starting MQSC for queue manager QMGRNAME" but after that it does not print any other prompts. Simply enter your commands to begin, and use the END command when you are done.



Saving interactive MQSC output

On IBM i, Linux and UNIX systems you can save the output from MQSC commands as you run them interactively.


    Linux and UNIX

    You can save the output from runmqsc (and almost any other program) using the 'script' tool, which is part of the operating system. Run the script command and provide the name of a file to which the output should be logged, then start your interactive runmqsc session. When you are done, type 'exit' or use Ctrl-D to stop logging to the file:

    sh> script mqoutput.txt
    sh>
    runmqsc QMGRNAME
    5724-H72 (C) Copyright IBM Corp. 1994, 2011.  ALL RIGHTS RESERVED.
    Starting MQSC for queue manager QMGR.

    DISPLAY QSTATUS(SYSTEM.CLUSTER.*) TYPE(HANDLE)
         1 : DISPLAY QSTATUS(SYSTEM.CLUSTER.*) TYPE(HANDLE)
    AMQ8450: Display queue status details.
       QUEUE(SYSTEM.CLUSTER.REPOSITORY.QUEUE)
       TYPE(HANDLE)                            APPLTAG(amqrrmfa)
       APPLTYPE(SYSTEM)                    
    AMQ8450: Display queue status details.
       QUEUE(SYSTEM.CLUSTER.COMMAND.QUEUE)     TYPE(HANDLE)
       APPLTAG(amqrrmfa)                       APPLTYPE(SYSTEM)

    END
         2 : END
    2 MQSC commands read.
    No commands have a syntax error.
    All valid MQSC commands were processed.
    sh> exit
    Script command is complete. The file is mqoutput.txt.

    IBM i Command Line

    1. Issue the command RUNMQSC QMGRNAME to start an MQSC session against a specific queue manager, or use WRKMQM option 26 to choose from a list of queue managers.
    2. Issue your MQSC commands against the queue manager.
    3. Before exiting, press F6 to save the output to a QSYSPRT spool file.
    4. Use F3 to exit, then use either WRKJOB option 4, or WRKSPLF to examine the spool file. You can use option 5 to display its contents or package the spool files for transfer to IBM.



Saving MQSC output using a text input file

If you have a series of commands whose output you want to save more than once, create a text file with one MQSC command per line. You may omit the END command since runmqsc will stop when it reaches the end of the file. Start runmqsc using your text file as input and redirect the output to a new file.


    Linux and UNIX

    1. Create a text file using your favorite editor, for example:

      sh> vi /tmp/mqcmds.txt

    2. Enter or paste the MQSC commands and save the file.
    3. In the shell, use "<" to redirect the new file as input to runmqsc and use ">" to redirect the output to a new output file:

      sh> runmqsc QMGRNAME < /tmp/mqcmds.txt > /tmp/mqoutput.txt


    Windows

    1. Create a new file, for example with Notepad or Wordpad.
    2. Enter or paste the MQSC commands and save the file as a plain text document with no formatting or line breaks.
    3. In a Command Prompt window ("cmd" under the Start menu) use "<" to redirect the file as input to runmqsc and use ">" to redirect the output to a new file:

      C:\> runmqsc QMGRNAME < %TMP%\mqcmds.txt > %TMP%\mqoutput.txt


    IBM i Command Line

    1. Create a new source file member and start the source entry utility (SEU):

      ===>
      CRTSRCPF FILE(QGPL/MQSRC) MBR(MQCMDS) TEXT('MQSC Commands')
      ===>
      STRSEU SRCFILE(QGPL/MQSRC) SRCMBR(MQCMDS) OPTION(2)

    2. Type or past the MQSC commands you want to run. Use the line command I (Insert) to add lines. Press HELP or F1 to review online help for SEU, if needed.
    3. Once the MQSC commands have been added to the file, press F3 to exit and then press enter to save the new member.
    4. Start MQSC using the new source file member as input. The system will generate a QSYSPRT spoolfile containing the output:

      ===> STRMQMMQSC SRCFILE(QGPL/MQSRC) SRCMBR(MQCMDS) MQMNAME(QMGRNAME)

    5. Use WRKSPLF or use WRKJOB option 4 to examine the spool file. You can use option 5 to display its contents or package the spool files for transfer to IBM.


    IBM i Qshell

    1. Before entering the Qshell, create a file in the Integrated File System with EDTF:

      ===> EDTF STMF('/tmp/mqcmds.txt')

    2. Enter or paste the MQSC commands you want to run. Use the line command I (Insert) to add lines. Press HELP or F1 to review online help for EDTF.
    3. Once the MQSC commands have been added to the file, press F3 twice to exit.
    4. In the Qshell use "<" to redirect the new file as input to runmqsc and use ">" to redirect the output to a new output file.

      ===> /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGRNAME < /tmp/mqcmds.txt > /tmp/mqoutput.txt





Saving MQSC output using echo

If you just need the output of one or two MQSC commands, you do not have to create a text file. Instead, use 'echo' to send one MQSC command per line to runmqsc and redirect the output to a new file. You may omit the END command since runmqsc will stop when it detects last one, but be sure to enclose the commands in quotes when using echo.


    Linux and UNIX

    sh> echo "ALTER QLOCAL(TEST.QUEUE) DEFPSIST(YES)
    DISPLAY QLOCAL(TEST.QUEUE) ALL" | runmqsc QMGRNAME > /tmp/mqoutput.txt


    Windows

    C:\> ECHO "START CHANNEL(PARIS.TO.NEWYORK)
    DISPLAY CHSTATUS(PARIS.TO.NEWYORK)" | runmqsc QMGRNAME > %TMP%\mqoutput.txt


    IBM i Qshell

    ===> ECHO "DISPLAY QMSTATUS" | /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGRNAME > /tmp/mqoutput.txt




Saving MQSC output using a here-document

The IBM i Qshell and most command shells on Linux and UNIX support a kind of redirection called here-documents which you can use with runmqsc. Here-documents are most useful when writing shell scripts that interact with IBM MQ.

When you use "<<" to redirect input from q here-document, you must provide a keyword which marks the end of the here-document. Enter one MQSC command per line, followed by your chosen keyword on a line by itself. You may omit the END command since runmqsc will stop when it reaches the end of the here-document, or you may use END as your here-document keyword.


    Linux and UNIX

    sh> runmqsc QMGRNAME << THATS_ALL_FOLKS > /tmp/mqoutput.txt
    DISPLAY CLUSQMGR(*) ALL
    DISPLAY QCLUSTER(*) ALL
    DISPLAY CHSTATUS(*) ALL WHERE (CHLTYPE EQ CLUSSDR)
    THATS_ALL_FOLKS



    IBM i Qshell

    ===> /QSYS.LIB/QMQM.LIB/RUMQSC.PGM QMGRNAME << END > /tmp/mqoutput.txt
    ALTER QMGR MAXMSGL(104857600)
    ALTER QLOCAL('TEST.Queue') MAXMSGL(104857600)
    ALTER CHANNEL('Test.Svrconn') CHLTYPE(SVRCONN) MAXMSGL(104857600)
    END

Product Alias/Synonym

WebSphere MQ WMQ

Rate this page:

(0 users)Average rating

Document information


More support for:

WebSphere MQ
Configuration

Software version:

6.0, 7.0, 7.1, 7.5, 8.0

Operating system(s):

AIX, HP-UX, IBM i, Linux, Solaris, Windows

Software edition:

All Editions

Reference #:

1621085

Modified date:

2014-09-05

Translate my page

Machine Translation

Content navigation