Thursday, October 29, 2009

Using the command line to unpause/enable printers in Leopard

~~Nerd Content Ahead~~


With a recent upgrade to Leopard from Tiger, we're having a lot of issues where the computers are constantly pausing the printers locally on each machine. In Tiger, the user could resume the printer, but in Leopard the user requires admin rights to resume them. This is causing problems because student and teacher accounts in our division don't have admin rights. This means I have to go around to each computer and enter admin credentials to unpause them. This is a giant waste of time, so I want to use the command line or a script to unpause/enable them.

So after much research and fiddling, I finally figured it out!

I use three commands that I've put into a script, and send out via ARD with the UNIX command option. They will unpause/enable the printer so that users can resume printing.

Here are the commands:

#finds printers that are currently disabled and clears the queue on them
cancel -a `lpstat -t | grep disabled | awk '{print $2}'`
#re-enable stopped print queues
cupsenable `lpstat -t | grep disabled | awk '{print $2}'`
#checks to see that all printers are re-enabled. should return nothing
lpstat -t | grep disabled | awk '{print $2}'

The only issue I've come across is that if the printer is being unpaused immediately following it being paused, then remove the top command which clears the queue, and just run the second two. This won't clear the queue, and unpause the printer so that the job goes through immediately.

I know there is a larger problem with the way our queues and printers are setup, so this is just a quick fix in the meantime, but I'm pretty proud of myself for figuring out this much as it is saving me a ton of work and headaches.

1 comment:

Nathan said...

I find it extremely amusing that a user can't resume their own print job, I certainly believe that it should restrict a user from resuming another user's print job, but this seems like a pretty simple piece of functionality.

Congrats on figuring this out. I'm glad you don't have to walk around from computer to computer anymore.