Skip to main content

Is there a way that we can delete printer that user added? we have a open directory that teacher can pick what printer they want to add. now we have new system that only uses one virtual printer, and we already push that one using LPD. what we want to happen is to remove all printer that they add and only printer one printer will stay the one that we push.

Precisely that!


I can't tell you how long I've looked for a way to do that!  Cheers, sir! 


If you go back to a Mac where your script failed on, and run:



lpstat -p | awk '{print $2}'


That will give you a list of all the CUPS printer names on the Mac. You can then compare to your script. I'm almost certain you will find differences in the names.



Hi, the script is giving me this error:

 

Script result: Deleting Printer: Xerox_C60
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.

 

Anyway the name is correct... any tips?


Removing all printers from a Mac before adding new ones can be done with this script.



#!/bin/bash

lpstat -p | awk '{print $2}' | while read printer
do
echo "Deleting Printer:" $printer
lpadmin -x $printer
done


This script has broken the printer setting pane. 

Now I can't see any new printer after adding it.
I tried to right-click and reset printer settings or to reset the system preferences completely and nothing helped.
Please help me 


Reply