Remove members from Queue

I needed to do this today with multiple queues. Maybe this can help others…

#!/bin/sh

if [ "$*" == "" ]; then
  echo "need to know which queues"
  echo "usage: $0 queue1 queue2 queue3 ..."
  exit
fi

for i in  $*
do
  CNTR=`/usr/sbin/asterisk -rx "queue show ${i}" | grep "from-internal" | awk '{print $1}'`
  for j in  ${CNTR}
  do
    echo "running: /usr/sbin/asterisk -rx queue remove member ${j} from ${i}"
echo    `/usr/sbin/asterisk -rx "queue remove member ${j} from ${i}"`
  done
done