Author |
Message
|
goffinf |
Posted: Thu Apr 29, 2010 12:25 pm Post subject: Ant and mqsichangeflowstats |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
Broker version: 6.1.0.3
Ant version: 1.7.0
o/s: Windows
I am writing an Ant script which needs to execute mqsichangeflowstats. First I tried this :-
Code: |
<exec executable="mqsichangeflowstats.exe" failonerror="false">
<arg value="${flowstats.broker.name}"/>
<arg value="-${flowstats.collection.mode}"/>
<arg value="-g"/>
<arg value="-j"/>
<arg line="-c"/>
<arg value="active"/>
<arg line="-t"/>
<arg value="${flowstats.thread.mode}"/>
<arg line="-n"/>
<arg value="${flowstats.node.mode}"/>
<arg value="-r"/>
<arg line="-o"/>
<arg value="xml"/>
</exec>
|
When I ran this I got the message :-
Code: |
The user environment was not adequately prepared to continue execution. Locate and run the profile supplied with the product. This file is called mqsiprofile.cmd .... |
So I thought, OK, I'll run mqsiprofile first in a separate but depnedant task. No change ... hmmm
A search within this forums archive yielded this comment from jeff lowrey to a similar question:-
Quote: |
I think if you look at the shortcut for the Command Console, then you can incorporate that into your exec command. Basically, all it does is run the Windows command prompt but tell it to include the mqsiprofile.cmd.
On unix, you would say exec=". <mqsi_install>/mqsiprofile;" and then pass mqsicreatebar as the first <arg>.
|
Excellent. But ... try as I might I can't get this to work on Windows ?? This was the sort of thing I have tried :-
Code: |
<exec executable="cmd.exe" failonerror="false">
<arg line="/c mqsiprofile.cmd mqsichangeflowstats.exe"/>
... rest as above
</exec>
|
The mqsichangeflowstats.exe doesn't execute (although mqsiprofile *does* execute in the command window).
So... at present I'm using a pretty ugly work-around, whereby I'm setting the various environment variables from mqsiprofile within the exec task (see below). But I really like Jeff's idea better, Can anyone point me in the right direction ?
Thanks
Fraser.
Current task (working - but ugly) :-
Code: |
<exec executable="mqsichangeflowstats.exe" failonerror="false">
<env key="MQSI_FILEPATH" path="${MQSI_FILEPATH}"/>
<env key="MQSI_WORKPATH" path="${MQSI_WORKPATH}"/>
<env key="MQSI_JREPATH" path="${MQSI_JREPATH}"/>
<env key="PATH" path="${MQSI_FILEPATH}\bin;${env.Path};"/>
<env key="LIB" path="${MQSI_FILEPATH}\lib;${env.lib};"/>
<env key="INCLUDE" path="${MQSI_FILEPATH}\include;${env.include};"/>
<env key="MQSI_CONSOLE_NLSPATH" path="${MQSI_FILEPATH}\messages\"/>
<env key="MQSI_DEVELOPMENT" value="SOFTWARE\IBM\WebSphereMQIntegrator\2"/>
<env key="MQSI_REGISTRY" path="${MQSI_WORKPATH}"/>
<env key="MQSI_JARPATH" path="${MQSI_FILEPATH}\classes;${MQSI_FILEPATH}\messages;"/>
<env key="MQSI_LILPATH32" path="${MQSI_FILEPATH}\bin;${MQSI_FILEPATH}\jplugin;"/>
<env key="MQSI_SECURITY_PROVIDER_PATH32" path="${MQSI_FILEPATH}\bin;"/>
<env key="MQSI_EXMLTCONFIGPATH" path="${MQSI_FILEPATH}\exmltConfig"/>
<env key="DISTHUB_PATH" path="${MQSI_FILEPATH}"/>
<env key="MQSI_CATALINA_HOME" path="${MQSI_FILEPATH}\catalina"/>
<env key="CLASSPATH" path="${MQSI_FILEPATH}\classes\configutil.jar;${MQSI_FILEPATH}\classes\ConfigManagerProxy.jar;${MQSI_FILEPATH}\classes;${MQSI_FILEPATH}\messages;${MQSI_WORKPATH}\common\wsrr;${MQSI_FILEPATH}\classes\com.ibm.mq.jar;${env.CLASSPATH}"/>
<env key="PATH" path="${MQSI_JREPATH}\bin;C:\Program Files\IBM\WebSphere MQ\bin;${env.Path}"/>
<arg value="${flowstats.broker.name}"/>
<arg value="-${flowstats.collection.mode}"/>
<arg value="-g"/>
<arg value="-j"/>
<arg line="-c"/>
<arg value="active"/>
<arg line="-t"/>
<arg value="${flowstats.thread.mode}"/>
<arg line="-n"/>
<arg value="${flowstats.node.mode}"/>
<arg value="-r"/>
<arg line="-o"/>
<arg value="xml"/>
</exec> |
|
|
Back to top |
|
 |
mqjeff |
Posted: Fri Apr 30, 2010 4:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I believe you'll find that exec starts a new shell.
you either need to execute mqsiprofile *before* you run your ant script, or do something different than you've tried to make sure that mqsiprofile runs inside the shell that is calling mqsichangeproperties.
I haven't played with ANT in several years, so I can't comment on how to do that last one. Maybe there's a way to tell windows shell to run two commands - like the ";" on unix.
Don't set the environment variables yourself. that's a maintenance nightmare. |
|
Back to top |
|
 |
goffinf |
Posted: Fri Apr 30, 2010 6:01 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
mqjeff wrote: |
I believe you'll find that exec starts a new shell. |
Indeed it does.
mqjeff wrote: |
you either need to execute mqsiprofile *before* you run your ant script, or do something different than you've tried to make sure that mqsiprofile runs inside the shell that is calling mqsichangeproperties. |
Yes thats what I'm attempting. I have tried running msqiprofile with its own exec and then a second for the mqsichangeflowstats but that doesn't work since they are separate command 'shells'.
mqjeff wrote: |
I haven't played with ANT in several years, so I can't comment on how to do that last one. Maybe there's a way to tell windows shell to run two commands - like the ";" on unix. |
Yes, I think thats what jeff lowery was getting at and thats what I was attempting with part the code I showed, i.e, create a command shell (cmd.exe, then pass the command to execute (mqsiprofile) and pass the 'chained' command (mqsichangeflowstats) as an argument :-
Code: |
<exec executable="cmd.exe" failonerror="false">
<arg line="/c mqsiprofile.cmd mqsichangeflowstats.exe"/>
... rest as above
</exec>
|
Actually looking again at this example I haven't quite done as I described, so I'll have another go and report back if anything changes.
mqjeff wrote: |
Don't set the environment variables yourself. that's a maintenance nightmare. |
I agree, and whilst that works for now, its not an approach I'm at all comfortable going forward with.
Thanks for your comments
Fraser. |
|
Back to top |
|
 |
goffinf |
Posted: Fri Apr 30, 2010 8:21 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
Update.
I *can* use exec to call a batch file which then calls both mqsiprofile and mqsichnageflowstats.
I'm not over-keen on this though because the number of arguments that are passed for the mqsichangeflowstats is more than 9, which means (for DOS) using SHIFT (and thus means the solution isn't portable), plus I need to be able to run mqsichangeflowstats with different parameters from the same Ant script and this introduces still more logic into the batch file.
So I'm still holding out for trying to figure out how to combine the mqsiprofile call and mqsichangeflowstats from a single Ant exec ?
Fraser. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Apr 30, 2010 10:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Alternatively you could have Ant create the batchfile instead of passing parameters to it. Then Ant could execute that batchfile...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Fri Apr 30, 2010 10:16 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
Thinking of my past experiences I used to call a batch file as you did here but I then used ant to replace substitution variables within that, rather than passing them directly to it.
I guess this is similar to fjbs suggestion but it may be sutably different (depending on what he meant by creating the batch file) so I thought i'd give it a mention  |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Fri Apr 30, 2010 10:20 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
|
Back to top |
|
 |
goffinf |
Posted: Sat May 01, 2010 4:48 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
WMBDEV1 wrote: |
.... I used to call a batch file as you did here but I then used ant to replace substitution variables within that, rather than passing them directly to it.
|
Hi mate,
nice to hear from you again.
Was this the sort of thing you had in mind :-
With a batch subsTemplate.bat containing :-
Code: |
@echo off
echo Hello @firstName@
echo Ant is @antOpinion@
echo WBIMB is @wbimbOpinion@
|
... and an Ant target like this :-
Code: |
<target name="batchFile_substitutionVaraiables">
<copy file="subsTemplate.bat" tofile="subs.bat">
<filterset>
<filter token="firstName" value="Fraser" />
<filter token="antOpinion" value="Great !" />
<filter token="wbimbOpinion" value="Better :-)" />
</filterset>
</copy>
<exec executable="cmd">
<arg value="/c"/>
<arg line="subs.bat"/>
</exec>
</target>
|
When subs.bat runs it produces :-
Code: |
Buildfile: build.xml
batchFile_substitutionVaraiables:
[copy] Copying 1 file to C:\Data\java\ANT\AntTests\ant
[exec] Hello Fraser
[exec] Ant is Great !
[exec] WBIMB is Better :-)
BUILD SUCCESSFUL
Total time: 0 seconds
|
|
|
Back to top |
|
 |
WMBDEV1 |
Posted: Sun May 02, 2010 3:36 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
goffinf wrote: |
Was this the sort of thing you had in mind :-
|
Yeah, you got it mate. Looks good.
Quote: |
nice to hear from you again.
|
Sure, its good to see you're still active on here also.
I dont get much free time these days and not being on an MQ contract atm I find it difficult to make time to offer updates on here but I still try and help out when I can  |
|
Back to top |
|
 |
|