/build/static/layout/Breadcrumb_cap_w.png

Managing Printers on OS X with KACE

Manipulating Printers on OS X

As with nearly everything for OS X, there are ways to accomplish adminitration tasks via the command line and via the GUI. Printing is no different. Since the focus here is to use these tips to manage OS X systems via the K1000 and K2000, this article will concentrate on the command line options.

The printers on OS X are controlled using CUPS* (Common Unix Printing System) which has its own set of command line tools.

The basics are:

  • Viewing Printers
  • Adding Printers
  • Removing Printers
  • Changing Printer options
  • Viewing Print queues

Viewing Printers

Short answer:

  /usr/bin/lpstat -p     (shows all printers)
  /usr/bin/lpstat -d     (shows default printer)

Middle answer:

system_profiler SPPrintersDataType  (shows all details in System Profiler for all Printers)

Easy Answer: The K1000 already gathers some of this. 

Also, if you have enabled the web interface to CUPS (sudo cupsctl WebInterface=yes), you can reach it via the web:

http://localhost:631/admin             (from the local machine)
http://KACE_HOST_IP:631/admin (via Machine Actions)  

Adding Printers
Short Answer:

/usr/bin/lpadmin  (with parameters)

Example:

lpadmin -p "Epson 831" -v "lpd://192.168.3.10/" -D "Epson Color Printer" -L "Koach Office" -P "/Library/Printers/PPDs/Contents/Resources/EPSON\ Artisan\ 830.gz" -o printer-is-shared=false -E

 

OK, so let's break this down. Note, not all options are required, such as -L for Location"

-p Printer name (queue name if sharing the printer)
-v IP address of printer (or DNS name)
-D Printer description (this is what will be displayed when users choose a printer)
-L Location of printer
-P Path to printer driver file
-o CUPS option. in this case turning off printer sharing, which is ON by default. 
-E Enable the printer

more parameters are available, see 'man lpadmin'.


Removing Printers
Short Answer:

  /usr/bin/lpadmin -x <printer_name>

Remove all Printers:

/usr/bin/lpstat -p | grep printer | awk {'print $2'} | xargs -I{} lpadmin -x {}

 

Changing Printer options
(There is good news and bad news about lpoptions... It does change the option, but not in the GUI. If you want hte option set and visible in the GUI for the end users to see, you need to set the option(s) when you install the printer. This can be done using the '-o' parameter and any of the options available via the loptions command.)


Short Answer:

/usr/bin/lpoptions -p <printername> -l    (lists all current options and settings.)

Example:

 lpoptions -p Epson835__Artisan_830 -l
EPIJ_PSrc/Page Setup: *2 3
EPIJ_Size/Paper Size: 1 *4 5 29 76 74 70 97 25 6 43
EPIJ_Medi/Media Type: *0 92 13 97 2 15 27 12 26 76 93
EPIJ_Ink_/Grayscale: *1 0
...

Note: leaving off the '-l' parameter will return information, but it won't be what you want.

The command will show all the options available and settings. 
For example, the duplex options are in there, listed as:
EPIJ_DSPr/2-sided Printing: *0 1

This indicates that 2-sided Printing is an option and it is disabled (the asterix is next to the 0 indicating 'false').

When changing an option via the command line, only use the real name of the option, not the friendly name.

/usr/bin/lpoptions -p printername -o EPIJ_DSPr=1 (would set the Duplex option to True)

Options may vary from manufacturer to manufacturer. HP Lists the duplex option as:
HPOption_Duplexer/Duplex Unit: *True False


Viewing Print queues

/usr/bin/lpq


Printing (via command line)
Short Answer: /usr/bin/lpr <filename>

Example: 

lpr /etc/hosts

You may not like the formatting; it is based off the terminal window size, font, etc.


* I am not going to document all the options for CUPS, there are a ton. It can be used to set up pretty much anything to do with printing and runs as a Daemon fontrolled by launchd. For more information see: 
http://en.wikipedia.org/wiki/CUPS
http://www.cups.org/index.php
http://www.cups.org/documentation.php/ref-cupsd-conf.html


Comments

  • MacDude. I'm looking to create a smart label based on where a person in the office sits and if they do not have the closest printer installed. Then I will create a MI or script to add this missing printer and apply it to this smart label. This looks like a great start for me, thanks a lot for sharing this. -Ben - bens401 9 years ago
This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ