ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General Discussion » Passing MQTMC2 to batch file in windows

Post new topic  Reply to topic
 Passing MQTMC2 to batch file in windows « View previous topic :: View next topic » 
Author Message
ldyoung71
PostPosted: Fri May 02, 2008 6:15 am    Post subject: Passing MQTMC2 to batch file in windows Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Fri May 02, 2008 6:24 am    Post subject: Reply with quote

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
View user's profile Send private message
ldyoung71
PostPosted: Fri May 02, 2008 6:44 am    Post subject: what programming language Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Fri May 02, 2008 7:01 am    Post subject: Re: what programming language Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Fri May 02, 2008 2:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
ldyoung71
PostPosted: Tue May 06, 2008 11:22 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue May 06, 2008 11:26 am    Post subject: Reply with quote

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
View user's profile Send private message
ldyoung71
PostPosted: Tue May 06, 2008 1:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Wed May 07, 2008 1:20 am    Post subject: Reply with quote

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
View user's profile Send private message
ldyoung71
PostPosted: Wed May 07, 2008 10:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » Passing MQTMC2 to batch file in windows
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.