Adding another sentence in addition to what Rob and T. Rob said.
MQ v7.1 and higher come with the dmpmqcfg command, and you can use this to check for a specific queue.
The following examples correspond to your sample, which checks if the queue manager is running:
To use dmpmqcfg to check if a queue name of any type exists, you can do this:
if dmpmqcfg -m ${QMgr} -t queue -x object -o 1line -n ${QName}|egrep '^DEFINE '; then
echo "Queue ${QName} exists on Queue Manager ${QMgr}
fi
Rob Parker, *, , :
* . DISPLAY Q( DISPLAY QLOCAL(
if printf "DISPLAY Q(${QName})" | runmqsc ${QMgr} 2>&1 >/dev/null; then
echo "Queue ${QName} exists on Queue Manager ${QMgr}
fi
:
if dspmq -m ${QMgr}| grep --quiet '(Running)'; then
echo "Queue Manager ${QMgr} is Running"
fi