When writing a script, it is often easier to define a set of variables at the beginning of the script. This makes any changes to the naming conventions or number of MQe objects easier to manage.
In TCL variables are defined using the set command and referenced using a $ in front of the variable name.
set PATH "C:\\MQeScript\\gateway"
When calling MQe_Script commands, they can be defined on their own or TCL control structures can be added to provide feedback on the success of the command and potentially exit the script if errors occur.
if { [catch {mqe_script_qm -create -qmname $GATEWAYQM -qmpath $PATH} error] } { puts "An error occurred creating queue manager"; puts "The reason was: $error" exit } else { puts "Queue manager created" }
As the above code snippet shows, the puts command is used to print text to the screen and the exit command stops the execution of the script. If any errors are thrown, the error text is saved in the variable named “error” and can then be accessed.
for {set j 1} {$j <= $QNUM} {incr j} { #create all the client connections mqe_script_mqconn -create -clientconnname $CC$j -proxyname $PROXY -bridgename $BRIDGE -syncqname $SYNCQ$j -port $PORT }The above snippet shows how names can be created using a loop variable. $CC is already defined as a client connection name prefix and $SYNCQ as a sync queue name prefix.
The code snippet also introduces the use of the # to define a comment.
source {C:\MQeScript\gatewayscript.tcl}For more information on TCL and writing scripts, refer to the documentation accompanying MQe_Script.