Checking for iPrint Objects With Missing PPDs

A few days ago I posted some notes about using iprntcmd to display some information about the print objects in your iPrint server. Today I’m going to talk about using iprntcmd to do a little sanity checking as well. If your institution is anything like mine, you’ve got pockets of Mac users and pockets of Windows users. They all need to print, and very seldom do they dare cross into each other’s realm. Generally this means that everyone is happy when it comes to printing. But from time to time, someone does cross into the opposing realm and discovers that they are unable to install a printer on their nice new Mac.

The reason is generally two fold. 1) They are probably missing the needed driver. 2) The iPrint object may actually be missing the PPD that tells OS X which driver to look for. Hopefully it’s obvious to most how to resolve the first problem, and if you’ve got even a so-so Novell administrator you will hopefully still have no problems solving the second item. But wouldn’t it be nice to get ahead of this problem before those daring few decide to cross into enemy territory and then call you in for reinforcements? Sure it would, so let’s do that.

Listing Printers on a Server

The command is simple and it was already covered here.

iprntcmd -L your-iprint-server.com

You can ask the iPrint server some basic questions about the printer URIs that you’ll see in the result

iprntcmd -i ipp://your-iprint-server.com/ipp/Name_Of_Print_Object_Here

The output of which might look something like this:

iprntcmd v05.06.00
Getting information on printer ipp://x.x.x.x/ipp/Awesome_Lanier130.
 State: Idle
 Accepting: Yes
 Number of jobs: 0
 Driver/PPD name:
 Role for this user: User
 Security: None
 Direct print: Disabled
 Location: 2nd floor conference room (across the hall from main office)
 Comments:

Scripting A Solution

See how it outputs the Driver/PPD name and how it’s all empty ‘n junk? That’s what we’re looking for. All that’s left now is to package this up in a script that loops over every print object and tells us which ones have a blank Driver/PPD name value. You’re welcome:

#!/bin/bash
function checkServer
{
 server="${1}"
 echo "======CHECKING FOR MISSING PPDs ON SERVER ${server}"
 for printer in `iprntcmd -L "${server}" | sed -n "3,100000p" | sed "s/^[ ]*//"`
 do
   driver=`iprntcmd -i "${printer}" | grep "Driver" | sed "s/^[^:]*:[ ]*//"`
   if [ "${driver}" == "" ]
   then
     echo "${printer}"
   fi
 done
}
# the checkServer command accepts the iPrint server address.
# If you have multiple iPrint servers, call it multiple times
# in your script, like this:
checkServer "iprint-a.example.com"
checkServer "iprint-b.example.com"

Extra Credit – Extracting PPDs From Driver Packages

In the example output above, we would need to find a PPD for the Lanier 130 model. The same instructions apply to other makes and models, but if you can find the print driver package on Apple’s website, you’re going to get everything you need.

Start by heading over to support.apple.com, search for “lanier printer drivers” and pick the result that has the most recent release date and version. In the case of a Lanier, you’ll end up here. Download the driver dmg and open it. You’ll notice that you can’t right click on the pkg installer within to see its package contents. That doesn’t mean we can’t get to them:

pkgutil --expand /Volumes/Lanier\ Printer\ Drivers/LanierPrinterDrivers.pkg ~/Desktop/LanierPrinterDrivers.pkg-e
Note: I use .pkg-e for the extension just so I never confuse an expanded package with the original, but this is completely optional.

Now that the pkg is expanded on the Desktop, finding the PPD is pretty simple:

cd ~/Desktop/LanierPrinterDrivers.pkg-e/LanierPrinterDrivers.pkg/
open Payload
cd Library/Printers/PPDs/Contents/Resources/
ls | grep -i 130

First we’re changing directories into our expanded pkg. Then we’re extracting the contents of the Payload file with the built-in open command. Finally, we’re changing directories into the land of the PPDs, listing its contents and grepping for anything with “130” in the name since we need a PPD for the Lanier 130.  The result in this case is LANIER LD 130C.gz and LANIER LD 130CSR.gz. It’s up to you to determine which PPD is appropriate for your 130, but once you’ve done that all that’s left is to email it to your Novell admin and ask very nicely that it be added to the Awesome_Lanier130 print object.

There you have it. You can audit your iPrint environment for incomplete print objects, locate the missing PPDs that need to be added to make those print objects complete, and hey, look at that, you’ve already got the Lanier print driver installer downloaded. Might as well push that out to your customers too. An easy “right-now” way to do that is by using Apple Remote Desktop, but I’d strongly recommend hiring a helper Munki.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s