Skip to main content

Saving WebSphere MQ MQSC output


Technote (FAQ)


Question

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

Answer

WebSphere 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 output from the 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:

  • IBM i Command Line
        ===> RUNMQSC QMGR

  • IBM i Q Shell
        ===> /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGR

  • Linux and UNIX
        sh> runmqsc QMGR

  • Windows
        C:\> runmqsc QMGR

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


Saving Interactive MQSC Output

On some systems you can save the on-screen output when you use runmqsc interactively.

  • IBM i Command Line
    1. Issue the command RUNMQSC QMGR 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 follow these "Collecting the joblogs" instructions to save the spool file for transfer to IBM.


  • Linux & UNIX
    On UNIX and Linux systems, you can save the on-screen output from runmqsc (and almost any other program) using the "script" tool, which is part of the operating system. Give "script" the name of the file to which the output should be logged, then begin your interactive runmqsc session. When you are done with runmqsc, type "exit" or Ctrl-D to stop logging to the file:
      sh> script mqsc-log.txt
      sh>
      runmqsc QMGR
      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 mqsc-log.txt.
      sh>

Saving Batch MQSC Output Using an Input File

On all systems you can process MQSC commands in batch (non-interactive) mode. If you have MQSC commands which you want to use more than once, it is best to put them in a text file with one MQSC command per line. Start runmqsc with the text file as input, and redirect the output to a new file. You can omit the END command since runmqsc will exit automatically after the last command:

  • IBM i Command Line
    1. CRTSRCPF FILE(QGPL/MQSRC) MBR(MQCMDS) TEXT('MQSC Commands')
    2. STRSEU SRCFILE(QGPL/MQSRC) SRCMBR(MQCMDS) OPTION(2)
    3. 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 SEU.
    4. Once the MQSC commands have been added, press F3 to exit.
    5. Press enter to save the member.
    6. Use the STRMQMMQSC command to run the script against the queue manager:

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

    7. The system will generate a QSYSPRT spoolfile with the output. Use either WRKJOB option 4, or WRKSPLF to examine the spool file. You can use option 5 to display its contents or follow these "Collecting the joblogs" instructions to save the spool file for transfer to IBM.

  • IBM i Q Shell
    1. Before entering the Q shell, create a file in the Integrated File System with EDTF:

          ===> EDTF STMF('/tmp/mqsc-cmd.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, press F3 twice to exit.
    4. In the Q shell (QSH or STRQSH), use "<" to redirect the file as input to runmqsc and use ">" to redirect the output to a new file.

          ===> /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGR < /tmp/mqsc-cmd.txt > /tmp/mqsc-out.txt

  • Linux & UNIX
    1. Create a text file using your favorite editor, for example:

          sh> vi /tmp/mqsc-cmd.txt

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

          sh> runmqsc QMGR < /tmp/mqsc-cmd.txt > /tmp/mqsc-out.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 QMGR < mqsc-cmd.txt > mqsc-out.txt

Saving Batch MQSC Output Using Echo

If you only need to run one or two MQSC commands, you can skip the step of creating a text file to hold the input commands. Instead, pipe the output from "echo" to runmqsc. Enter one MQSC command per line, with a quotation mark before the first command and after the last one. You can omit the END command since runmqsc will exit automatically after the last command:

  • IBM i Q Shell

        ===> ECHO "DISPLAY QMSTATUS" |
        /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGR > /tmp/mqsc-out.txt

  • Linux & UNIX

        sh> echo "ALTER QLOCAL(TEST.QUEUE) DEFPSIST(YES)
        DISPLAY QLOCAL(TEST.QUEUE) ALL" |
        runmqsc QMGR > /tmp/mqsc-out.txt

  • Windows

        C:\> ECHO "START CHANNEL(PARIS.TO.NEWYORK)
        DISPLAY CHSTATUS(PARIS.TO.NEWYORK)" |
        runmqsc QMGR > %TMP%\mqsc-out.txt

Saving Batch MQSC Output Using a Here-Document

Most command shells on UNIX and Linux, and the Q shell on IBM i, support a kind of redirection called here-documents which you can use with runmqsc. Here-documents are more often used when writing scripts that interact with WebSphere MQ than when using the shell yourself.

When you redirect input from a here-document with "<<", you must give a keyword to identify the end of the here-document. Enter one MQSC command per line, followed by your chosen keyword on a line by itself. You can omit the END command since runmqsc will exit automatically after the last command, or you can use "END" as your here-document keyword:

  • IBM i Q Shell

        ===> /QSYS.LIB/QMQM.LIB/RUNMQSC.PGM QMGR << END > /tmp/mqsc-out.txt    ALTER QMGR MAXMSGL(104857600)    ALTER QLOCAL('Test.Queue') MAXMSGL(104857600)    ALTER CHL('Test.Svrconn') CHLTYPE(SVRCONN) MAXMSGL(104857600)    END



  • Linux & UNIX

        sh> runmqsc QMGR << THATS_ALL_FOLKS > /tmp/mqsc-out.txt    DISPLAY CLUSQMGR(*) ALL    DISPLAY QCLUSTER(*) ALL    DISPLAY CHSTATUS(*) ALL WHERE (CHLTYPE EQ CLUSSDR)    THATS_ALL_FOLKS





Product Alias/Synonym

WebSphere MQ WMQ

Rate this page:

(0 users)Average rating

Copyright and trademark information

IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.

Rate this page:


(0 users)Average rating

Add comments

Document information

WebSphere MQ

Configuration


Software version:
5.3, 6.0, 7.0, 7.1, 7.5


Operating system(s):
AIX, HP-UX, IBM i, Linux, Solaris, Windows


Software edition:
All Editions


Reference #:
1621085


Modified date:
2013-01-11

Translate my page

Content navigation