Author |
Message
|
ldyoung71 |
Posted: Fri May 02, 2008 6:15 am Post subject: Passing MQTMC2 to batch file in windows |
|
|
Newbie
Joined: 05 Dec 2007 Posts: 8
|
I've been reading in discussions where users mention that you can pass the MQTMC2 structure so that you can pass information to the application that you want to start. All I want to do is be able to trigger the amqsget app and be able to pass the qname and qmanager name. So the batch file I will trigger is called EMPTYQUEUE.BAT. I need it to do something like this: amqsget <QName> <QManager>. Where qname and qmanager are passed into the batch file. How do I pass the MQTMC2 structure into a simple batch file so that I can get those values? |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri May 02, 2008 6:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The default trigger monitor will invoke your program with the MQTMC2 structure as the first command argument.
So in your batch script, you can do things to break the first argument up into it's pieces, and pass the Queue and Queue Manager name to amqsget. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
ldyoung71 |
Posted: Fri May 02, 2008 6:44 am Post subject: what programming language |
|
|
Newbie
Joined: 05 Dec 2007 Posts: 8
|
Would you recommend writing a JAVA app to do this? So there is no way to just pass the values into the batch file without using a programming language? |
|
Back to top |
|
 |
Vitor |
Posted: Fri May 02, 2008 7:01 am Post subject: Re: what programming language |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ldyoung71 wrote: |
Would you recommend writing a JAVA app to do this? |
It depends on what method you're happiest using to cut up a structure.
ldyoung71 wrote: |
So there is no way to just pass the values into the batch file without using a programming language? |
As my associate most correctly points out, the default trigger monitor passes the TMC2 structure for the benefit of the triggered application.
Here are two other options you might want to consider:
- Don't use the default trigger monitor. Write a different trigger monitor which just passes the values you're interested in and use that.
- Modify the amqsget code you're trying to trigger with this batch file to interpret the TMC2 structure as it's intended to be used. IIRC there's an example triggered application, and you'll probably need to modify amqsget anyway to use it as you seem to be trying to (to empty a queue).
I'd recommend the second method personally. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri May 02, 2008 2:26 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
One way to cut it up is to nest invocation levels.
This is the pitfall of most triggered programs because you have to go to some length to conserve the trigger structure as you go to the next invocation level...
Example
triggered.bat
call triggered_lvl2.bat %1
Now the parameters in triggered_lvl2 will not be one structure but the list of arguments as separated by spaces ...
This changes some if you had
call triggered_lvl2.bat '"%1"'
So no programming needed, just a little shell scripting, which ever way you take it...
We had even one script being triggered, create the script for execution, call it, remove it when done....
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ldyoung71 |
Posted: Tue May 06, 2008 11:22 am Post subject: |
|
|
Newbie
Joined: 05 Dec 2007 Posts: 8
|
I'm a little confused. Are you saying that I can call one batch file, pass the structure, then call another batch file to pass the queue name and qmgr name? This is what i have below.
This batch file is defined in the trigger process.
empty1.bat
c:\empty2.bat %1 %2
empty2.bat only has the following command in it.
amqsget %1 %2 |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue May 06, 2008 11:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
ldyoung71 wrote: |
I'm a little confused. Are you saying that I can call one batch file, pass the structure, then call another batch file to pass the queue name and qmgr name? This is what i have below.
This batch file is defined in the trigger process.
empty1.bat
c:\empty2.bat %1 %2
empty2.bat only has the following command in it.
amqsget %1 %2 |
This is close..
You just need something in empty1.bat to turn the MQTMC2 into the right %1 and %2 you want to pass to amqsget.
I don't know how to process strings in Windows batch files - but the MQTC2 is just a string value. So if you can split it on things, or substring it or etc, you should be able to extract the queue and queue manager name. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
ldyoung71 |
Posted: Tue May 06, 2008 1:06 pm Post subject: |
|
|
Newbie
Joined: 05 Dec 2007 Posts: 8
|
Actually I was able to pull the MQTMC2 structure but need to parse through it to get the 48 character queue name and 48 character qmgr name. I need to figure out a way to do that within the batch file. That would be ideal. Thanks for your help! |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 07, 2008 1:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ldyoung71 wrote: |
I need to figure out a way to do that within the batch file. |
If it was me (and it's not) I'd produce a triggered version of amqsget that interogates the structure directly. Cut out the batch file, which adds nothing to the value of the process.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
ldyoung71 |
Posted: Wed May 07, 2008 10:18 am Post subject: |
|
|
Newbie
Joined: 05 Dec 2007 Posts: 8
|
The problem is that I have not written any type of code in quite a few years. Primarily just an admin now. I was looking at some batch commands to figure out how I could pull the qname and qmgr name. I noticed a FINDSTR command. If I could pull the data from a set position in the triggerdata string it would work, but I can't figure out how to use the FINDSTR command to do exactly that. The input data is 1 line. All I need is a command to search for characters 9-54. Then set that to a constant. Then do something similiar to find the next value(the qmgrname). I guess it is not possible. |
|
Back to top |
|
 |
|