Author |
Message
|
tbonium |
Posted: Wed Jul 29, 2009 12:58 pm Post subject: MQSC Scripting Using Variables |
|
|
Newbie
Joined: 28 Jul 2009 Posts: 3
|
I have a MQSC script which creates all of the MQ objects for a given queue manager. My deployment process involves running a batch file that creates the queue manager and executes the runmqsc.exe file passing in the MQSC script file as a parameter. With in the script file I would like to reference variables for environment specific configuration items. For example in the following channel definition:
DEFINE CHANNEL ('CHANNEL_NAME') CHLTYPE(SDR) +
TRPTYPE(TCP) +
CONNAME('SERVERNAME(PORTNUMBER)') +
XMITQ('TRANSMIT.QUEUE') +
REPLACE
I would like to reference a variable supplied by the batch file to for the values of SERVERNAME and PORTNUMBER in the CONNAME.
Can anyone please tell me how to do this? |
|
Back to top |
|
 |
gbaddeley |
Posted: Wed Jul 29, 2009 4:03 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
Use a windows command line search-and-replace tool to process the parameterised MQSC script file, and feed the output into runmqsc. _________________ Glenn |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Wed Jul 29, 2009 11:37 pm Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
I've used ant in the past, it has some nice features here. |
|
Back to top |
|
 |
Michael Dag |
Posted: Thu Jul 30, 2009 9:52 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
WMBDEV1 wrote: |
I've used ant in the past, it has some nice features here. |
Can you give a sample of using ant in combination with MQSC scripts?
i have never used it myself and have no clue where to start with ant...  _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
WMBDEV1 |
Posted: Thu Jul 30, 2009 10:42 am Post subject: |
|
|
Sentinel
Joined: 05 Mar 2009 Posts: 888 Location: UK
|
|
Back to top |
|
 |
tbonium |
Posted: Sun Aug 02, 2009 6:31 pm Post subject: Working on using a batch script |
|
|
Newbie
Joined: 28 Jul 2009 Posts: 3
|
I'll just put it out there that I am newbie to WMQ. Maybe I am a bit ignorant but I'm pretty surprised that there is a scripting language developed that does not support the use of variables. Anyway, my thanks for the suggestions. I'm currently looking into replacing values in the script via batch commands. I'll post the results of my quest. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Aug 03, 2009 3:40 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
MQSC is more of a command language than a scripting language.
It is not in any sense a programming language at all. There are no branches of any kind, so it is not even capable of building finite automata, much less any higher order computational structure. |
|
Back to top |
|
 |
gbaddeley |
Posted: Mon Aug 03, 2009 4:42 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
Here is an example of using a batch command file on Windows to create a queue manager and define objects, including sender / receiver channels to / from another queue manager. It uses Windows environment variables to parameterise object names and attributes:
Code: |
set QM=MQGBX8
set PORT=1418
set RMTQM=MQGBX9
set RMTHOST=localhost
set RMTPORT=1419
crtmqm -u SYSTEM.DEAD.LETTER.QUEUE %QM%
strmqm %QM%
echo def listener(%QM%.LISTENER) trptype(TCP) replace control(QMGR) port(%PORT%) >%QM%.in
echo def ql(QL1) replace >>%QM%.in
echo def ql(%RMTQM%) replace usage(XMITQ) trigdata(%QM%.TO.%RMTQM%) + >>%QM%.in
echo initq(SYSTEM.CHANNEL.INITQ) trigtype(FIRST) trigger >>%QM%.in
echo def chl(%QM%.TO.%RMTQM%) chltype(SDR) replace conname('%RMTHOST%(%RMTPORT%)') + >>%QM%.in
echo trptype(TCP) xmitq(%RMTQM%) discint(300) >>%QM%.in
echo def chl(%RMTQM%.TO.%QM%) chltype(RCVR) replace >>%QM%.in
echo start listener(%QM%.LISTENER) >>%QM%.in
runmqsc %QM% <%QM%.in >%QM%.out
type %QM%.out
pause |
Using lots of echo commands is a bit messy, but it works, and no other software like search/replace tools or ANT is required. _________________ Glenn |
|
Back to top |
|
 |
gbaddeley |
Posted: Mon Aug 03, 2009 4:44 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
The Unix equivalent is similar, but uses only one echo command. I can post it if anyone is interested. _________________ Glenn |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Aug 04, 2009 5:44 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Please.  _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 04, 2009 6:30 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I'd guess that the Unix version will use a single echo with a HERE doc rather than a succession of echo commands.
Kinda not surprised to learn that windows doesn't support HERE docs. |
|
Back to top |
|
 |
gbaddeley |
Posted: Tue Aug 04, 2009 3:12 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
Due to popular request, here is the equivalent in Unix Korn Shell Script:
Code: |
#!/usr/bin/ksh
QM="MQGBX8"
PORT="1418"
RMTQM="MQGBX9"
RMTHOST="localhost"
RMTPORT="1419"
crtmqm -u SYSTEM.DEAD.LETTER.QUEUE $QM
strmqm $QM
echo "def listener($QM.LISTENER) trptype(TCP) replace control(QMGR) port($PORT)
def ql(QL1) replace
def ql($RMTQM) replace usage(XMITQ) trigdata($QM.TO.$RMTQM) +
initq(SYSTEM.CHANNEL.INITQ) trigtype(FIRST) trigger
def chl($QM.TO.$RMTQM) chltype(SDR) replace conname('$RMTHOST($RMTPORT)') +
trptype(TCP) xmitq($RMTQM) discint(300)
def chl($RMTQM.TO.$QM) chltype(RCVR) replace
start listener($QM.LISTENER) " >$QM.in
runmqsc $QM <$QM.in >$QM.out
cat $QM.out |
I didn't bother using HERE docs ( http://en.wikipedia.org/wiki/Here_document ), as I wanted the MQSC command input and output to be recorded on files.
Its useful for Unix MQ administrators to know some shell script programming.
HTH _________________ Glenn |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Aug 04, 2009 6:34 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What's one more redirection between friends? |
|
Back to top |
|
 |
Michael Dag |
Posted: Wed Aug 05, 2009 12:55 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
|
Back to top |
|
 |
exerk |
Posted: Wed Aug 05, 2009 1:12 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Yes please!  _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
|