I have about 50 HP JetDirect print queues on an AIX system that I wanted to remove in a more automated way. The following KSH script is what I came up with to remove the device and queue.

The script attempts to ping the print queue (queues are added by DNS name). If the ping fails, I remove the device using rmqueudev and then remove the queue using rmque.


for i in $(lpstat | awk '{print $1}')

ping -c 1 -w 1 $i >/dev/null 2>&1

if [ $? -ge 1 ];
    echo "Purging $i"
    rmquedev -q $i -d hp@$i
    rmque -q $i

After running this, I have 6 valid print queues that remain on the AIX system.