Initializing the current command environment with setmqenv

If you receive an error message indicating that an IBM® MQ command is unknown or unavailable, use the setmqenv command to initialize the current command environment so that the operating system can find the appropriate command.

About this task

Each operating system uses the directories in the PATH environment variable to determine which program to run. If none of the directories in the current PATH environment variable include an executable program of the specified name, this causes the operating system to respond with a message indicating that it could not locate the command, as shown in the following examples:
  • [UNIX][Linux]On UNIX and Linux®:
    % dspmqver
    ksh: dspmqver:  not found.
    %
  • [Windows]On Windows:
    C:\> dspmqver
    'dspmqver' is not recognized as an internal or external command,
    operable program or batch file.

To resolve this issue, you should use the setmqenv command to initialize the current environment so that the appropriate IBM MQ commands can be located and executed by the operating system.

Procedure

  1. Locate where the setmqenv command is on the available file systems.
    • [UNIX][Linux]On UNIX and Linux:
      % find / -name setmqenv 2>/dev/null
      ...
      %
    • [Windows]On Windows:
      C:\> dir /b /s C:\setmqenv.cmd
      ...
      
      C:\>
      Note: If multiple drive letters exist, they may be included, for example: C:\> dir /b /s C:\setmqenv.cmd D:\setmqenv.cmd .

      Directories with source, or Maint can be ignored since they almost always refer to a backup copy of the command created during the installation of a fix pack.

  2. Use the setmqenv command to initialize the current environment.
    • [UNIX][Linux]On UNIX and Linux:
      % . <pathtoexecutable>/setmqenv -s
      %
      On UNIX and Linux, the setmqenv command must be sourced so the current environment can be modified.
    • [Windows]On Windows:
      C:\> <pathtoexecutable>\setmqenv.cmd -s
      ...
      
      C:\>
  3. Verify that the environment is suitable for the appropriate IBM MQ installation by using the dspmq command with the -o installation option.
    • [UNIX][Linux]On UNIX and Linux:
      % dspmq -o installation
      ...
      %
    • [Windows]On Windows:
      C:\> dspmq -o installation
      ...
      
      C:\>
  4. If necessary, run the setmqenv command again, with adjusted parameters, to initialize the environment for a more appropriate installation of IBM MQ.
    For example:
    • [UNIX][Linux]On UNIX and Linux:
      % dspmqver | grep Version
      Version:     8.0.0.15
      
      % dspmq -o Inst | sed -e "s/          //g"
      QMNAME(V8QM1)     INSTNAME(Installation1) INSTPATH(/opt/mqm) INSTVER(8.0.0.15)
      QMNAME(SPIDEY)    INSTNAME(Installation4) INSTPATH(/opt/MQ91CD) INSTVER(9.1.5.0)
      QMNAME(BOB)       INSTNAME(Installation3) INSTPATH(/opt/MQ92) INSTVER(9.2.2.0)
      
      % . setmqenv -n Installation3
      
      % dspmqver | grep Version
      Version:     9.2.2.0
      Note: The setmqenv command must still must be sourced so the current environment can be modified.
    • [Windows]On Windows:
      C:\> dspmqver | findstr Version
      Version:     9.1.0.5
      
      C:\> dspmq -o inst | sed -e "s/          //g"
      QMNAME(A)         INSTNAME(Installation2) INSTPATH(C:\IBM\MQ91LTS) INSTVER(9.1.0.5)
      QMNAME(B)         INSTNAME(MQ91CD) INSTPATH(C:\IBM\MQ91CD) INSTVER(9.2.2.0)
      QMNAME(C)         INSTNAME(MQ92) INSTPATH(C:\IBM\MQ92) INSTVER(9.2.2.0)
      
      C:\> setmqenv -n MQ92
      
      C:\> dspmqver | findstr Version
      Version:     9.2.2.0