Cornelius Qualley
Cornelius Qualley

Reputation: 761

Return printer queue name (description) using lpstat - OS X

Okay, in short, I'm trying to return a printer list from my system to determine whether a specific printer is present and, if not, automatically setup that printer. Using the lpstat command, specifically:

lpstat -a | awk '{print $1}'

I can get a list returned but the printer names do not match my queue names, which is what I really need. my question is whether there is a way to return the queue names rather than the actual printer name? I'm running this as a shell script in AppleScript on OS X.

When I run the command, I'm getting a printer name returned as "EPSON_TM_T88V" rather than my printer queue name of "Printer 1"

Upvotes: 0

Views: 1985

Answers (1)

McUsr
McUsr

Reputation: 1409

Last time I looked into this, Apple used the Cups printer system, that should be installed on your system.

First you should execute cupsctl WebInterface=yes in a terminal window (you will be prompted for the administrator password.

Then you can try to visit the address (http://localhost:631/printers/?) this is a page you should be able to curl output from, so that you can extract the printer name from the queue name.

And this works for me, visually, maybe you have set up printersharing and the like as well.

A second solution I know of that may help, is that Stefan Klieme, has written a faceless application that listens for Bonjour Events named (Bonjour Events) that you should be able to download, and when you have, you should drop the app onto the library window of AppleScript Editor to see the dictionary. I think however for the Bonjour Events to work, your printer must be up and running, whereas the Cups approach works when the printer is offline.

What I sadly can't remember, is if I set up Cups myself, or if it sets up itself, by interfacing with the Printer Settings in the Systems Preferences panel.

However, I hope this helps.

Upvotes: 3

Related Questions