Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Managing multiple printers via the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Managing multiple printers via the command line
Authored by: mlc on Dec 23, '06 09:37:09PM
Thanks for the tip. I've found that if you use the -D flag (description), you can have a name that includes spaces. If the description is set, then the printer will show up in OS X with that name instead of the formal name. I've revised the the script to include checking for the printer prior adding, and to include a few HP LaserJet print options as well. Hope this helps.

#!/bin/bash

# Tests to see if printer exists - sidesteps a variable scope issue
# Requires the printer name as a parameter.  Returns 1 if the printer exists.
function printerExists()
{
  if [ $# -ne 1 ]; then
    echo "Incorrect parameters"
    return 0
  else
    lpstat -p | awk '{print $2}' | while read printer
    do
      if [ $1 = "${printer}" ]; then
        return 1
      fi
    done
  fi	
}


# Printer Name cannot Include any spaces
prName="formalName"
# User friendly printer name"
prDescription="Printer Name"
# Location
prLocation="Home Office"
# IP Address of printer
prAddress="192.168.1.99"
# PPD Filename... assumes it is installed on machine
prPPD="HP LaserJet 2200.gz"

#Test If Printer is already installed
printerExists $prName
prExists=$?

if [ $prExists -eq 1 ]; then
  echo "Printer already exists. Skipping: \"$prName\""
else
  # Add Printer Command 
  lpadmin -p "${prName}" -D "${prDescription}" -L "${prLocation}" \
  -E -v lpd://"${prAddress}" -P "/Library/Printers/PPDs/Contents/Resources/en.lproj/$prPPD" \
  -o HPOption_Duplexer=True -o Resolution=1200x1200dpi
fi


[ Reply to This | # ]
Managing multiple printers via the command line
Authored by: mikerose on Jan 18, '07 01:35:44PM

Woohoo! This is great! I was able to research the correct options for my Canon machines via lpoptions -v ... and I'm now a printer-configuring machine. :-)



[ Reply to This | # ]
Anyone done this with Canon copiers?
Authored by: mikerose on Feb 05, '07 07:54:44AM

I may have spoken a bit too soon. My setup works perfectly with this script except for

lpoptions -d "MyCopier" -o EFFinisher="Finisher"

The machines in question are Canon 8070 copiers with the ImagePASS S1 RIP, which supports an option of "Finisher" for the K1 finisher unit. Although this is what shows up when you read the options from a manual configuration (via Printer Utility), it doesn't work the other way: setting it up from the command line doesn't show the finisher options in the Print dialog. :-(

any help appreciated.



[ Reply to This | # ]