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 » IBM MQ Installation/Configuration Support » MQSC Scripting Using Variables

Post new topic  Reply to topic
 MQSC Scripting Using Variables « View previous topic :: View next topic » 
Author Message
tbonium
PostPosted: Wed Jul 29, 2009 12:58 pm    Post subject: MQSC Scripting Using Variables Reply with quote

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
View user's profile Send private message
gbaddeley
PostPosted: Wed Jul 29, 2009 4:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
WMBDEV1
PostPosted: Wed Jul 29, 2009 11:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Michael Dag
PostPosted: Thu Jul 30, 2009 9:52 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
WMBDEV1
PostPosted: Thu Jul 30, 2009 10:42 am    Post subject: Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

I cant paste in the entire ant file but this is the task to do the replace:
http://ant.apache.org/manual/CoreTasks/replace.html

In addition to this you can get tasks to scp mqsc scripts to remote servers and then sshexec to the box to execute them:
http://ant.apache.org/manual/OptionalTasks/sshexec.html
http://ant.apache.org/manual/OptionalTasks/scp.html

With a little research you should be able to find a basic ant script and then include these tasks as needed.
Back to top
View user's profile Send private message
tbonium
PostPosted: Sun Aug 02, 2009 6:31 pm    Post subject: Working on using a batch script Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Mon Aug 03, 2009 3:40 am    Post subject: Reply with quote

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
View user's profile Send private message
gbaddeley
PostPosted: Mon Aug 03, 2009 4:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
gbaddeley
PostPosted: Mon Aug 03, 2009 4:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
bruce2359
PostPosted: Tue Aug 04, 2009 5:44 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Tue Aug 04, 2009 6:30 am    Post subject: Reply with quote

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
View user's profile Send private message
gbaddeley
PostPosted: Tue Aug 04, 2009 3:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Tue Aug 04, 2009 6:34 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

gbaddeley wrote:
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.


What's one more redirection between friends?
Back to top
View user's profile Send private message
Michael Dag
PostPosted: Wed Aug 05, 2009 12:55 am    Post subject: Reply with quote

Jedi Knight

Joined: 13 Jun 2002
Posts: 2607
Location: The Netherlands (Amsterdam)

If there is enough interest I could add this functionality (use of variables) to MQDocument's MQSC Generator
_________________
Michael



MQSystems Facebook page
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
exerk
PostPosted: Wed Aug 05, 2009 1:12 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

Michael Dag wrote:
If there is enough interest I could add this functionality (use of variables) to MQDocument's MQSC Generator


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
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 » IBM MQ Installation/Configuration Support » MQSC Scripting Using Variables
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.