In a recent update to MQSCX, a new feature was introduced which allows you to discover the machine OS that the script is running on.
This feature is aptly demonstrated by a new example script, mqauthlist.mqsx, available in our Example Scripts bundle. This script writes a report, and the file location of the output report needs to vary depending on whether the script is run on a Windows machine or on a Unix machine. So the script utilises a new MQSCX system variable, _os to determine where MQSCX is running, and thus the report location. Here’s how:-
** Set the output file path location based on the os type if( _os = "WINDOWS" ) @outputpath = "C:\MQSCX\Output\MQAuthlist\" else @outputpath = "/var/mqscx/output/mqauthlist/" endif
The @outputpath variable is then later used to build the file name that is opened to write the report to.
** Open file and write header @filename = @outputpath + "mqauthlist_" + date(_time, "_y_mm_d") + ".txt" @hf = fopen(@filename, "w")
The possible values of _os are:-
Clearly a lot of examples that come to mind will be the Windows vs not Windows decision as is illustrated in this script (and also in our fnamelist.mqx script in the bundle), but there may also be times when specific Unix based decisions might also be useful.
The best way to understand scripts is of course to have a go with them yourself. There are various examples in the download, so why not try them out yourself. If you are not currently an MQSCX licence holder, you may email firstname.lastname@example.org to request a trial licence.