Author |
Message
|
GeneRK4 |
Posted: Fri Feb 13, 2015 12:20 am Post subject: Running MQ scripts in ANT |
|
|
Master
Joined: 08 Jul 2013 Posts: 220
|
I want to run MQ scripts in ANT.
When we tried this,its not working.Its not able to detect the "<" in runmqsc.We tried with some options still not working..
If anyone successfully tried this,please share with me..
Here is the detail of our ANT script:
<?xml version="1.0"?>
<project name="project" default="queue.creation">
<property file="build.properties.txt"/>
<!-- Target to Create Queues -->
<target name="queue.creation">
<exec executable="${wmq.home}\runmqsc.exe">
<arg value="${queue.manager}" />
<arg value="<" />
<arg value="${queuefile.name}" />
</exec>
</target>
</project>
Result:
ant -buildfile queues.xml
Buildfile: queues.xml
queue.creation:
[exec] Usage: runmqsc [-e] [-v] [-w WaitTime [-x] [-m LocalQMgrName]] [QMgr
Name]
[exec] 5724-H72 (C) Copyright IBM Corp. 1994, 2009. ALL RIGHTS RESERVED.
[exec]
[exec] Result: 20
BUILD SUCCESSFUL
Total time: 0 seconds
=====================================
Result 20 Error- MQSC command file not run |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Feb 13, 2015 7:09 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
create a little batch program say
Code: |
@echo off
runmqsc %1 < %2.mqsc > %1_%2.log 2>&1 |
and run this batch program instead of runmqsc...
Should have the same effect and you don't have to mess with redirection...
You did not specify the platform, but I am sure you know which changes to make to the batch file to run under Unix/Linux...
And remember, in windows some things need to be run from an elevated command prompt...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
GeneRK4 |
Posted: Mon Feb 16, 2015 12:54 am Post subject: |
|
|
Master
Joined: 08 Jul 2013 Posts: 220
|
Created a batch file myrunmqsc.bat with the below contents:
@echo off
runmqsc %1 < %2
But getting the below error:
C:\Users\291861>ant -buildfile queues.xml
Buildfile: queues.xml
queue.creation:
[exec] Result: 255
BUILD SUCCESSFUL
==================================
Result:255 is error and hence it didnt work for us.
When we try to give runmqsc %1 < %2.mqsc > %1_%2.log 2>&1 in bat file its showing "> unexpected". |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 16, 2015 4:59 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
GeneRK4 wrote: |
Created a batch file myrunmqsc.bat with the below contents:
@echo off
runmqsc %1 < %2
But getting the below error:
C:\Users\291861>ant -buildfile queues.xml
Buildfile: queues.xml
queue.creation:
[exec] Result: 255
BUILD SUCCESSFUL
==================================
Result:255 is error and hence it didnt work for us.
When we try to give runmqsc %1 < %2.mqsc > %1_%2.log 2>&1 in bat file its showing "> unexpected". |
Can you give the exact command in the batch file between [ c o d e ] tags? And also how you call it from ant.
Have you looked at the log the command is writing to? It should show you exactly what went wrong and why...
You should not get any unexpected... unless you added some spaces where you shouldn't have...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
GeneRK4 |
Posted: Wed Mar 04, 2015 1:29 am Post subject: |
|
|
Master
Joined: 08 Jul 2013 Posts: 220
|
Though we gave as below,it didn't work
@echo off
runmqsc %1 < %2.mqsc > %1_%2.log 2>&1
ANT tasks were not able to recognize ‘<’ argument.
So we changed the batch file like below:
@echo off
runmqsc %1 %2 %3
where 1st parameter is Queue manager, 2nd parameter is ‘<’ and 3rd parameter is the file with MQSC commands.
And ANT task will be like this:
<!-- Target to Create Queues -->
<target name="Queue.creation">
<if>
<equals arg1="${createQueue}" arg2="yes" />
<then>
<echo message="Creating Queues.. "/>
<exec executable="${wmq.home}\myrunmqsc.bat">
<arg value="${queue.manager}" />
<arg value="<" />
<arg value="${queue.def}" />
</exec>
<echo message="Successfully created Queues" />
</then>
</if>
</target>
Its working fine now  |
|
Back to top |
|
 |
tsuru |
Posted: Thu May 21, 2015 1:26 pm Post subject: |
|
|
Novice
Joined: 25 Nov 2005 Posts: 24 Location: São Paulo
|
You must use a redirector (https://ant.apache.org/manual/Types/redirector.html) to redirect the script content to runmqsc
Code: |
<exec executable="runmqsc">
<arg value="${qmgr}"/>
<redirector input="script.mqsc" />
</exec> |
|
|
Back to top |
|
 |
|