2

I am running a script in which I want to detect the WebSphere MQ Version and if this version is 7.1, then I want to run a runmqsc to set channel authentication. I do this:

   <if>
        <or>
            <os name ="AIX">
            <os name ="Linux">
        </or>
    <then>
        <loginfo>Checking the installed MQ version.</loginfo>
             <osexec commandbase="su" dir="/bin" mode="osexec">

            <args>
                  <arg value="-"/>
                          <arg value="- ${mq_admin_name}"/>
                          <arg value="-c"/>
                          <arg line="dspmqver | grep Version"/>

            </args>
             </osexec>

        <if>
             <not>
              <not>
               <contains casesensitive="yes" substring="7.1.0.0" string="${result.output}"/>
              </not>
             </not>
        <then>
           ...........
           ..........

After this I use a runmqsc. But the problem is the string {result.output} is empty. The dspmqver command is not getting executed properly..can someone suggest why?

T.Rob
  • 31,522
  • 9
  • 59
  • 103
Tanu
  • 369
  • 5
  • 7
  • 18
  • Question - the Ant command is `exec` and FTE doesn't provide `osexec` so is `osexec` one of your internal Ant procedures? If this were a normal Ant `exec` command I'd expect to see an `outputproperty=result`. I have no idea whether `osexec` sets the result property internally but based on the code shown I would expect `result` to be empty. – T.Rob Nov 01 '12 at 15:48
  • @T.Rob .. Yes osexec is an internal Ant procedure. When I execute the same code with command as "dspmq | grep ${queue_manager_name}", and do this: then I get the output in the result.output. Then, why not in this case too? – Tanu Nov 01 '12 at 16:18
  • Without seeing the code for `osexec` or the actual output from `dspmqver` it's tough to say. Any particular reason you aren't providing diagnostic information or the code that actually performs the call that is failing? What about doing `Result of dspmqver: ${result.output} ${result.error}`? – T.Rob Nov 01 '12 at 16:28
  • @T.Rob .. Result of dspmqver: ${result.output} ${result.error} gives only Result of dspmqver: . Which makes me think result.output is empty. dspmqver gives this output: Name: WebSphere MQ Version: 7.1.0.0 Level: p000-L111015 BuildType: IKAP - (Production) Platform: WebSphere MQ for AIX Mode: 64-bit O/S: AIX 6.1 InstName: Installation1 InstDesc: InstPath: /usr/mqm DataPath: /var/mqm Primary: Yes MaxCmdLevel:710 – Tanu Nov 01 '12 at 16:36
  • Try it without the grep. When `dspmqver` fails, it usually gives an error but in this case, grep is suppressing anything that doesn't conform to the search pattern, hence the empty string. Also, any FDC files getting cut when this happens? Anything in `${MQ_INSTALL_PATH}errors/AMQERR01.LOG`? Instead of "How to check MQ version in Ant" this post might be better titled "how to get diagnostic information out of Ant" in which case this commentary wold be a point-earning answer. ;-) – T.Rob Nov 01 '12 at 17:14

1 Answers1

0

There is a bit of a mismatch here between the title of the post, "How to check Websphere MQ version in ant?", the conclusion that dspmqver isn't being executed properly, and the lack of diagnostic information.

  • The problem isn't how to check the WebSphere MQ version in Ant but rather how to perform exception handling and diagnosis in Ant.
  • The conclusion that dspmqver isn't being executed properly isn't supported. The code shown doesn't give any indication that it even gets as far as executing dspmqver.
  • The part of the code that performs the actual execution and sets the resultproperty isn't shown.

My suggestion is as follows:

  1. Validate that osexec populates result.error. I just guessed that property would be populated given the existence of result.output. If osexec doe not populate it, use what it does populate with STDERR or modify it to do do something with STDERR if it does not already.
  2. Right below </osexec>, add <loginfo>Call to dspmqver returned: STDOUT='${result.output}', STDERR='${result.error}'</loginfo>
  3. If nothing is returned, drop the grep. The dspmqver command should return something to STDERR or STDOUT and the grep is filtering it out if it doesn't exactly match the search string.
  4. If nothing is still returned, challenge the assumption that dspmqver is even being executed. If it is, it either returns something or cuts an FDC file. Any other behavior would be a bug in dspmqver and not solvable through Ant or in response to this post.

Basically, divide and conquer. Keep removing stuff until you get output. That will isolate the problem. Print useful diagnostics so once you isolate the problem you have some indication of what it is.

T.Rob
  • 31,522
  • 9
  • 59
  • 103