Date Created: Sun 10-Feb-2008

Related Document Categories:

Get my WebSphere MQ course here >> http://www.themiddlewareshop.com/products/



How to use a shell script to End a WebSphere MQ Queue Manager and poll status until complete.

endqm.sh

#!/bin/bash
# BASH Functions file
# Filename: endqm.sh
# Tested on OS: Linux, Fedora 6
# Author: Steve Robinson
# Date Created: February 2008
# Arguments: Queue Manager Name
# Decription: This script ends a queue manager and pools the Queue Manager status until ended
# Version: 1.0
# History:-
# 10-February-2008 - version 1.0 - Created.
###################################################################################
## Global Variables
###################################################################################
localHost=$(hostname)
_DEBUG="on"
###################################################################################
## Debug Function
###################################################################################
DEBUG()
{
[ "$_DEBUG" == "on" ] && $@ || :
}

#####################################################################################
## Main Routine
#####################################################################################

main() {

DEBUG echo "Status: Entering Main Routine.. "
DEBUG echo "Status: Checking to see if [$qmname] exists? ..."

qm=`dspmq | awk '{ print $1 }' | sed 's/QMNAME(//g;s/)//g' | grep -o $qmname`
if [ "$qm" = "" ];
then
DEBUG echo "Status: [$qmname] does not exist!"
`crtmqm $qmname`
DEBUG echo "Failure: Exiting with value 1"
else
DEBUG echo "Status: [$qmname] exists"
status=`dspmq -m $qmname| cut -d '(' -f2,3 | cut -d ')' -f2 | cut -d '(' -f2`
DEBUG echo status of queue manager [$qmname] is [$status]
if [ "$status" = "Running" ]
then
DEBUG echo "Status: Ending: [$qmname]"
endmqm $qmname

while [ "$status" != "Ended normally" ]
do
sleep 5
echo "Ending..."
status=`dspmq -m $qmname| cut -d '(' -f2,3 | cut -d ')' -f2 | cut -d '(' -f2`
done
DEBUG echo status of queue manager [$qmname] is [$status]
DEBUG echo "Success: Exiting with value 0"
fi
fi
}




####################################################################################
## Entry Point
####################################################################################
DEBUG echo There are $# arguments to $0: $*
#Checking environment variables
if [ ! "$1" ];
then
DEBUG echo "Failure: You must pass in a queue manager name"
DEBUG echo "exiting with value 1"
exit 1
else

qmname=$1
DEBUG echo "Status: Queue Manager to end = $qmname"
DEBUG echo "Status: Calling Main Routine ... "

main $*

DEBUG echo "Exit: Exiting Main Routine and Terminating script ... "
exit 0

fi

Get my WebSphere MQ course here >> http://www.themiddlewareshop.com/products/

Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


  • Linked In
  • Twitter
  • About Me
  • My Blog
  • Contact Me

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories