Skip to main content
Question

Reset Printing System from Command Line?

  • October 1, 2008
  • 4 replies
  • 16 views

Forum|alt.badge.img+8

Is anyone familiar with a way to run the Reset Printing System from the
command line? Since OSX 10.5 requires an administrator password just to add
and remove printers, I'm building a Self Service package that our end users
can use and I'd like to include a shell script that would allow them to
reset their printing system.

Thanks!

Robb Gibson
System Engineer - eMMS, Publishing Systems
OfficeMax : 263 Shuman Blvd. : Naperville, IL 60563
(630) 864-5242

4 replies

Forum|alt.badge.img+6
  • Contributor
  • July 25, 2012

I've used this in the past with success.

lpstat -p | cut -d' ' -f2 | xargs -I{} lpadmin -x {}


Forum|alt.badge.img+12
  • Contributor
  • July 27, 2012

another way to skin this cat with no call to external programs for text processing:

#!/bin/bash

# removes all printers using filename prefix from .ppd files

shopt -s nullglob

for file in /etc/cups/ppd/* ; do
    path=${file%.ppd};
    name=${path##*/};
    lpadmin -x ${name};
done

donmontalvo
Forum|alt.badge.img+36
  • Hall of Fame
  • June 6, 2013

Both of these work...are there any benefits/drawbacks for either?

#!/bin/bash
lpstat -p | cut -d' ' -f2 | xargs -I{} lpadmin -x {}
exit 0

or

#!/bin/sh
for file in /etc/cups/ppd/*
    do
      path=${file%.ppd}
      name=${path##*/}
      lpadmin -x "${name}"
    done
exit 0

tobiaslinder
Forum|alt.badge.img+16
  • Valued Contributor
  • June 9, 2013

The second one works fine with me. I let it run daily to get rid of all the bonjour printers the users set up.