Skip to content
Advertisement

script for deleting queues using a certain prefix

i have a file named “Output_File.txt” containing a list of local queues and i want to write a script to delete those queues. what i wrote is:

queuelist=`wc -l Output_File.txt | awk -F ' ' '{print $1}'`
for (( currentline=1; currentline<=queuelist; currentline++ ))
do
   currentqueue=`awk -v x="$currentline" 'NR==x {print $1}' Output_File.txt
   echo "delete qlocal( $currentqueue )" | runmqsc
done
echo "the queues were deleted"
exit 0

the problem is that the script does delete the queues but prints for every deleted queue the following output:

1 : delete qlocal ( -queue_name- )
AMQ8007: WEBSPHERE MQ QUEUE DELETED.
NO COMMANDS HAVE SYNTAX ERROR.
ALL VALID MQSC COMMAND WERE PROCESSED.

how can i alter the code to delete the queues without printing the output above? thanks.

Advertisement

Answer

just use echo "delete qlocal( $currentqueue )" | runmqsc > /dev/null inside your for loop to direct all output of that command to blackhole /dev/null

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement