Tag Archives: MQSCX_Jul2016

MQGem recently delivered a new version of MQSCX that supports the new IBM MQ V9 release. As well as support for the new command level, there were a number of other features in this new version of MQSCX. One of those new features was a bootstrap file. This is a well known named MQSCX script file that is always imported when you start up MQSCX. It can be a handy place to put any frequently used functions.

The bootstrap file can either have your frequently used functions included in it directly, or the bootstrap file can have =import file statements in it (or both). For example:-

Of course the bootstrap file could also be used to run a command, or a number of commands every time the program is started up. Anything you can do in a normal MQSCX script file (or interactively) you can put into the bootstrap file. Here’s one example, but of course I’m sure you can think of plenty of others.

I’m sure there are lots of other things you could do with the bootstrap file. Let us know in the comments if you have any other ideas.

If you are a current MQSCX licence holder, you can simply download the new version of MQSCX and start using it. If you’re not a current licence holder, and you’d like to try out MQSCX, please email support@mqgem.com to request a trial licence.

There are different types of users who use MQSCX. Some like the interactive experience, with tab auto-complete of commands, keywords and objects names. Others like the ability to create and edit CCDT files suitable for any required version of IBM MQ. Others again like the powerful control language which makes writing scripts to interrogate your queue manager a breeze.

Freaking awesome, Paul! I wrote several reporting scripts for a customer a couple of months back. They declined to purchase MQSCX so I was forced to do much of the logic in the script, giving me I have a good basis for comparison of both approaches. The differential in lines of code, complexity and amount of additional billable time I spent would have paid for a site license for several years. The ROI is now more than doubled, possibly even 5x what it was.

Sometimes those different use cases come together. The control language has a for loop concept where you can easily iterate over all the queue manager objects that are returned by the command server as the answer to an MQSC command, with a script something like this:-

Now with MQSCX V9.0.0 you can use the powerful control language to analyse and manipulate your CCDT files. Another example of using the foreach construct on a CCDT file can be see in Be sure of your CCDT Version

If you are a current MQSCX licence holder, you can simply download the new version of MQSCX and start using it. If you’re not a current licence holder, and you’d like to try out MQSCX, please email support@mqgem.com to request a trial licence.

MQGem recently delivered a new version of MQSCX that supports the new IBM MQ V9 release. As well as support for the new command level, there were a number of other features in this new version of MQSCX. One of those new features was a popular customer request for the addition of functions to the MQSCX control language.

There are some new examples available in our Example Scripts bundle, which demonstrate how to use functions. In this blog post we’re going to take a look at one of those samples, conns.mqx as a way to introduce you to functions. This function evolved from an earlier blog post, MaxChannels vs DIS QMSTATUS CONNS where it was used to demonstrate all the different ways application connections show up in a queue manager.

The first thing to notice comparing the script in the earlier blog post, to the one in the sample download, is that the code is topped and tailed by the following statements:-

func conns()
:
endfunc

This is how you define a function in the MQSCX control language. All the statements in between the func and endfunc statements make up the body of your function.

If you load up the sample into MQSCX by importing the file, and then show the contents of the function with the =show func(conns) list command, you’ll also see that the comments that immediately precede the function in the imported file are included in this display. A handy place to describe what your function does to remind you in the future.

You can run the function simply by typing its name on the command line.

[16:58:32] conns

Total connections: 23

Local : 21

QMgr Chls : 0

Client Chls: 2

Total Running Channel instances: 1

QMgr Channels: 0

Client Channels: 1

MQG1>

The next comparison to make between this function and it’s original form in the earlier blog post, is use of the =echo statements. The intention of this script (in both cases) is that you don’t see all the commands and responses going to and from the command server, you just see the final totals printed on the screen. For the original script this meant at the start it switched off commands and responses, and then at the end, switched them back on again.

=echo cmds(NO)
=echo resp(NO)
:
=echo cmds(YES)
=echo resp(YES)

This would have the slightly undesirable effect that if you had either of those turned off before you ran the script, the script would inadvertently turn them back on again when it was done!

In the new version where the script is wrapped into function, there is only one =echo statement at the top.

=echo resp(NO)

There is no need to switch responses back on again because the =echo statement only applies inside the function. The function is a black box to any callers. It doesn’t impact any settings, such as these =echo settings, on the caller. Also notice that the default inside a function is that the commands are not shown anyway.

Functions aren’t just handy for wrapping your scripts into handy re-usable chunks, but also functions are very useful when they are parameterised. In this blog post we’re going to make some changes to the supplied conns() function to add a parameter. At the moment it totals all your connections. Now we’ll give it a parameter of an application name (or part of one) and it can total just those connections.

To indicate that a function has a parameter, the parameter name goes between the parentheses on the func conns() statement. When you later refer to that parameter in your script statements within the function you prefix it’s name with the ‘@’ symbol to show that it is a user variable.

func conns(ApplTag)
:
@ApplTag ...

In the MQSCX control language, parameters are not mandatory. We are still allowed to call the conns() function without giving it a parameter – if we code it that way. This would be a handy thing to have; without a parameter it totals everything, with a parameter it filters the totals by that application.

The way to achieve this – to have a parameter that can be optional – is to ensure that everywhere the parameter is used is preceded by a test to see if it exists. Now, I want to use the parameter more than once; first to check it against the APPLTAG that comes back from a DISPLAY CONN command, and then to check it against the RAPPLTAG that comes back from a DISPLAY CHSTATUS command. So rather than checking it exists multiple times, right up front I’ll test it and set it to a useful value if it doesn’t exist.

if (!exists(@ApplTag))
@ApplTag = ""
endif

Now I can use the @ApplTag variable throughout the rest of the function with impunity.

In the old version of the script it just counted the totals that came back from a command issued to the command server – now it needs to look at the output to see whether the APPLTAG attribute contains the string supplied in the parameter. So let’s replace the initial two display commands with the following:-

Clearly if you ask to filter by an application name, none of the queue manager channel connections are going to match, but this code will still work when we don’t want to filter by anything because the findstri function returns TRUE when asked if the string contains the empty string.

N.B. findstri is the case insensitive version of findstr.

We also make a little tweak to the print out of the first line to reflect the use of the parameter by the user running the function.

And finally, the pre-existing foreach loop needs a little tweak. The DISPLAY CHSTATUS command is extended to also return the RAPPLTAG attribute, and then an if statement is added just as with the earlier for loop.

Clearly you could take these changes even further, perhaps adding a parameter to configure a detail level for the output, with high detail showing all the channel names. The possibilities are endless. We hope you find functions a very useful addition to your MQSCX scripts.

Here’s the final view of the updated function with all the changes described in this post.

If you are a current MQSCX licence holder, you can simply download the new version of MQSCX and start using it. If you’re not a current licence holder, and you’d like to try out MQSCX, please email support@mqgem.com to request a trial licence.

MQGem recently delivered new versions of MO71 and MQSCX that support the new IBM MQ V9 release. As well as support for the new command level, they support other new IBM MQ V9 features. One such feature is the ability to have your Client Channel Definition Table (CCDT) hosted somewhere centralised, such as on an FTP server or web server. Prior to IBM MQ V9, this was only available to Java clients due to the fact that the language gave you the capability whenever you needed to specify a file name URI. Now in IBM MQ V9, ‘C’ clients (and unmanaged .NET clients) also have this feature.

MO71

You can either set the MQCCDTURL environment variable and the whole MO71 application will take note of it, or you can set it individually for specific locations by providing the CCDT URL in the location dialog. Open the Location, ensure the Client checkbox is ticked which enables two things, the Configure button – which is for defining your channel definition manually through the MQCNO, and the CCDT URL entry field, which is where you can put the URL of your hosted CCDT file. You don’t need both of course, and MQ defines a precedence order of which is used if you do specify both.

Specify your CCDT URL in the MO71 Location Dialog.Please note, the URL shown is for demonstration purposes only. There is no CCDT at the shown URL!

MQSCX

As with MO71, you can either set the MQCCDTURL environment variable and the whole MQSCX application will take note of it, or you can set it individually for specific locations by providing the ccdturl() on the =conn command.

If this feature interests you and you’d like to try it out for yourself on either of these products, and you are not currently a licence holder, you may email support@mqgem.com to request a trial licence.

MQGem Software is pleased to announce that a new version of MQSCX, our command line extended MQSC tool for IBM MQ, is now available.

The main features of the release are as follows:-

Support for MQ Command Level 900

As normal with a new release of IBM MQ, there is a new command level. MQSCX now supports this new command level and its contents.

foreach(…) loop now operates in CCDT mode

Previous releases of MQSCX allowed the use of the foreach(…) statement to process each response from the command server. This release extends that processing to work with the responses to commands issued against the CCDT. For more information see Scripts using foreach on the CCDT

New iteration system variables loops

New system variables _idxEach, _idxItem, _idxWhile, _numEach, _numItem and _numWhile which can make processing loops easier.

Support of CCDT URL

IBM MQ V9 allows a connecting application to specify the URL location of the CCDT file to use. This field can now be specified on the =conn command. For more information see Using the CCDT URL.

Support for functions

You can now define lists of commands which can be invoked from the command line, other functions or expressions. For more information see MQSCX functions, which has a worked example.

Support for GOTO

You can now jump to labelled parts of your code.

Automatically loads bootstrap.mqx file

This can be useful to load useful functions so they are always available. Although it could equally be used to always run a specific command or several commands every time the MQSCX tool is started. For more information see MQSCX Bootstrap file.

Various improvements to the usability of the debugger

Including commands to support the new functions capability, such as sf to set your current stack frame.

New eval() function

This function allows the user to create more dynamic expressions by having the contents of strings evaluated as an expression. For example, print eval(“curdepth > 0”).

The new version can be downloaded from the MQSCX Download Page. Any current licensed users of MQSCX can run the new version on their existing licence. If you don’t have a licence and would like to try out MQSCX then send a note to support@mqgem.com and a 1-month trial licence will be sent to you.