Running MQSC commands from batch files - Middleware News
If you have very long commands, or are using a particular sequence of commands repeatedly, consider redirecting stdin from a batch file. To do this, first create a batch file containing the MQSC commands using your usual text editor. When you use the runmqsc command, use the redirection operators. The following example:
Creates a test queue manager, TESTQM
Creates a matching CLNTCONN and listener set to use TCP/IP port 1600
Creates a test queue, TESTQ
Puts a message on the queue, using the amqsputc sample program
Example script for running MQSC commands from a batch file
export MYTEMPQM=TESTQM
export MYPORT=1600
export MQCHLLIB=/var/mqm/qmgrs/$MQTEMPQM/@ipcc
crtmqm $MYTEMPQM
strmqm $MYTEMPQM
runmqlsr -m $MYTEMPQM -t TCP -p $MYPORT &
runmqsc $MYTEMPQM << EOF
DEFINE CHANNEL(NTLM) CHLTYPE(SVRCONN) TRPTYPE(TCP) SCYEXIT('amqrspin(SCY_NTLM)')
DEFINE CHANNEL(NTLM) CHLTYPE(CLNTCONN) QMNAME('$MYTEMPQM') CONNAME('127.0.0.1($MYPORT)')
ALTER CHANNEL(NTLM) CHLTYPE(CLNTCONN) SCYEXIT('amqrspin(SCY_NTLM)')
DEFINE QLOCAL(TESTQ)
EOF
amqsputc TESTQ $MYTEMPQM << EOF
hello world
EOF
endmqm -i $MYTEMPQM
If you have very long commands, or are using a particular sequence of commands repeatedly, consider redirecting stdin from a batch file. To do this, first create a batch file containing the MQSC commands using your usual text editor. When you use the runmqsc command, use the redirection operators. The following example:
Creates a test queue manager, TESTQM
Creates a matching CLNTCONN and listener set to use TCP/IP port 1600
Creates a test queue, TESTQ
Puts a message on the queue, using the amqsputc sample program
Example script for running MQSC commands from a batch file
export MYTEMPQM=TESTQM
export MYPORT=1600
export MQCHLLIB=/var/mqm/qmgrs/$MQTEMPQM/@ipcc
crtmqm $MYTEMPQM
strmqm $MYTEMPQM
runmqlsr -m $MYTEMPQM -t TCP -p $MYPORT &
runmqsc $MYTEMPQM << EOF
DEFINE CHANNEL(NTLM) CHLTYPE(SVRCONN) TRPTYPE(TCP) SCYEXIT('amqrspin(SCY_NTLM)')
DEFINE CHANNEL(NTLM) CHLTYPE(CLNTCONN) QMNAME('$MYTEMPQM') CONNAME('127.0.0.1($MYPORT)')
ALTER CHANNEL(NTLM) CHLTYPE(CLNTCONN) SCYEXIT('amqrspin(SCY_NTLM)')
DEFINE QLOCAL(TESTQ)
EOF
amqsputc TESTQ $MYTEMPQM << EOF
hello world
EOF
endmqm -i $MYTEMPQM
Comments
Post a Comment