Help with clear printer queue script in AIX 5.3


 
Thread Tools Search this Thread
Operating Systems AIX Help with clear printer queue script in AIX 5.3
# 1  
Old 11-12-2012
Help with clear printer queue script in AIX 5.3

Good day UNIX forum, could you help me with my clear printer queue script, i have problems with the consistency of this function, sometimes it works sometimes it doesn't. Thanks in advance

Code:
}

preRemovePrintQ(){

clear;
echo;
echo "==============================================================================";
echo "### R E M O V E    P R I N T E R    Q U E U E";
echo "==============================================================================";
echo; echo;
echo "Enter print queue for removal: \c";
read queName;

while [ ! "$queName" ]
do
  echo "Enter print queue for removal: \c";
  read queName;
done

queNameT=`echo "$queName"|tr -cd [:alnum:]|tr A-Z a-z`;
preRemovePrintQ2;

}

preRemovePrintQ2(){

lsque -q $queNameT > /dev/null 2>&1;
if [ "$?" -eq "0" ]; then
  echo;
  echo "Are you sure you want to remove this print queue [yes/no]? \c";
  read prqAnswer;
  preRemovePrintQ3;
else
  echo;
  echo "Print queue \"$queNameT\" does not exists. Do want to try again [yes/no]? \c";
  read tryagain;
  tryagainAnswer;
fi;

}

  
tryagainAnswer(){

case "$tryagain" in 
    YES|yes|Yes|YeS|yeS|YEs|yES|yEs)
    preRemovePrintQ;
        ;;
    NO|no|No|N|n|nO)
    pause;
        ;;
  *)
    echo "Please answer [\"yes\" or \"no\"]: \c";
        read tryagainAnswer;
        tryagainAnswer;
        ;;
esac;

}


preRemovePrintQ3(){

 case "$prqAnswer" in 
    YES|yes|Yes|YeS|yeS|YEs|yES|yEs)
    goremovePrinterQue;
        ;;
    NO|no|No|N|n|nO)
    pause;
        ;;
  *)
    echo "Please answer [\"yes\" or \"no\"]: \c";
        read prqAnswer;
        preRemovePrintQ3;
        ;;
esac;
  
}

goremovePrinterQue(){

for qHere in `ls /var/spool/lpd/qdir/ | grep "$queNameT"`; do rm -f $qHere; done;

DevNam3=`lsque -q $queNameT|grep "device"|awk -F\= '{print $2}'|sed -e 's/^[ \t]*//'`;
/usr/lib/lpd/pio/etc/piomisc_ext rmpq_other  $queNameT:$DevNam3 'remote.local';
echo;
echo "-----------------------------------------------------------------";
echo "Printer queue \"$queNameT\" has been successfully removed. [OK].";
echo "-----------------------------------------------------------------";
echo;

}

# 2  
Old 11-20-2012
Code:
This might be unstable for some amounts of files:
 
$ for qHere in `ls /var/spool/lpd/qdir/ | grep "$queNameT"`; do rm -f $qHere; done;
 
Hopefully, the files are all at that level, and the $PWD is right. Normally 'ls' just lists entry names,
 so to remove them you have to have that as pwd, and then why not just say '*' ?
 
I prefer something like this, with fewer fork/exec, robust for any number of files, works from any pwd, uses shorter relative names:
 
$ cd /var/spool/lpd ; find qdir -type f -name "*$queNameT*" | xargs -n999 rm -f


Last edited by DGPickett; 11-20-2012 at 05:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remote print from SLES (SAP) to AIX 7.1 04 sp2 virtual printer queue gets down

Hello Administrators. I have a bit difficult problem. I have local virtual printer that has backend defined in /etc/qconf to script which in turns sends the spool to the real device. whenever I print locally (from sap) the print works as it should. The printer queue after the print is done... (6 Replies)
Discussion started by: Deneth
6 Replies

2. UNIX for Dummies Questions & Answers

Printer queue not clearing

Hi I have installed an HP X451dw printer on our network and want to print from Sco Openserver v6 The printer produces correct output but then repeats until the queue is manually stopped. :confused: It is using a netcat/dumb interface Any advice on how to persuade it to only print once... (5 Replies)
Discussion started by: David Holmes
5 Replies

3. AIX

AIX Bunch of printers queue creation script - HELP

I'd seek for help on how to create a bunch of printers in AIX 6.x or equal or above in one go – say like I have 35 printers to create in 4 different AIX Nodes every month – I currently create it manually like below:- How can I automatic this creation on all the 4-5 Nodes – not actually automatic... (3 Replies)
Discussion started by: shiv2001in
3 Replies

4. AIX

Problem with Queue of the Printer

Guy's This is the Queue of the printer ... >lpstat -pTOPPRINTER Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- --------- --- ------------------ ---------- ---- -- ----- --- --- TOPPRIN @TOPP DOWN QUEUED ... (1 Reply)
Discussion started by: ITHelper
1 Replies

5. AIX

Cannot setup a printer queue

So I've got this asc file that someone sent me for setting up a Zebra printer on AIX. When I use smit or the command line I get this error when I try to setup the printer up: File /usr/lib/lpd/pio/predef/master does not exist. The master file is there. This only happens when I setup a... (2 Replies)
Discussion started by: Hurmoth
2 Replies

6. UNIX for Advanced & Expert Users

Ho to clear a MQ queue :

Hi All, Can anyone tell me how to clear list of queues in a file? My file FILE1 has 3 queues FILE1 FirstQueue SecondQueue ThirdQueue I want to clear all these queues which belong to the same Qmanager from another script... Can anyone help me for this.. Thanks in... (0 Replies)
Discussion started by: Ch Bushu
0 Replies

7. Solaris

Cancel printer queue permission

How to assign permission for a user to cancel unix printer queue other than root? lprm -P and cancel? How to chmod for /bin/cancel to -rws-x-x --> s means? Please help. Thank you. (1 Reply)
Discussion started by: KhawHL
1 Replies

8. AIX

Check printer queue on Windows printer server

Hello Let me first give a small overview of the setup. All printers are connected to Windows 2000 servers. There are a lot of UNIX (AIX & HP-UX) servers as well which have SAP running. I'm working on a script to add printers to a specified SAP instance. I want to verify the user input (to... (0 Replies)
Discussion started by: NielsV
0 Replies

9. AIX

Printer Queue not getting created

When I try to create first print queue in this system with the command line argument, find the output also... # /usr/lib/lpd/pio/etc/piomkjetd mkpq_jetdirect -p 'generic' -D pcl -q 'AR06_Workcenter_32' -h 'AR06_Workcenter_32' -x '9100' 0782-606 /usr/lib/lpd/pio/etc/piomgpdev: Error 'A file or... (1 Reply)
Discussion started by: giribt
1 Replies

10. HP-UX

Help adding a printer queue

Hello, I need some help on the following issue: Need to have a printer queue added to the "sssssss" server.The IP address is "xxx.xxx.xxx.xxx". It is an HP8000 printer. Can you please point me to the right direction. Thank you (0 Replies)
Discussion started by: AQG
0 Replies
Login or Register to Ask a Question