Submitted by anonymous on macosxhints.com
Adding and Removing a Printer
This is done via the lpadmin command. To add a printer, use this format:
lpadmin -p Printer_Name -L "Printer Location" -E -v lpd://x.x.x.x
Don't use spaces in the Printer_name. "Printer location" can be anything.
-P /Library/Printers/PPDs/Contents/Resources/en.lproj/Printer_Driver.gz
An IP address belongs in the x.x.x.x bit, and change lpd: to ipp: if that's what you use.
To remove a printer:lpadmin -x Printer_Name
To find out what printers are installed -- this one is great for
finding the names should you need them with the command above -- simply
use this:lpstat -p
If you want to see the current jobs
on a computer, simply use this command. (Note that this will show the
jobs for the specified printer. However, if you do not specify a
printer, it will show the jobs for all queues.)lpstat -o Printer_Name
To clear a queue of all jobs, we use lprm.
Note in this example the first hyphen is solo. This forces all jobs to
be cleared; more methods to clear individual jobs or those of a
particular are explained in the man page.lprm - -P Printer_Name
Clearing all queues
Unfortunately I could not find a command which removed all jobs from
all queues. So I wrote up a small script which does this for you. You
could deploy this as a shell script file and then execute it (good for
both SSH and ARD), or in the case of Apple Remote Desktop's "Send UNIX
Command" function, simply throw in the whole script and run it as root.#!/bin/bash
------end post-------
lpstat -p | awk '{print $2}' | while read printer
do
echo "Clearing Queue for Printer:" $printer
lprm - -P $printer
done
No comments:
Post a Comment