From: Greg Merritt (gmerritt@uclink.berkeley.edu)
Date: Thu Dec 05 2002 - 16:24:24 PST
In our department, we have a bunch of Classic OS Mac users
who print to a number of different printers, all scattered across
several different subnets; when the AppleTalk abatement starts to hit
us, most of these folks will find that a number of their defined
printers won't work as configured.
Faced with the prospect of setting up about 8 or more lpr
printers on each of about a couple dozen Macs, I figured that there
had to be a better way... I googled around and found some
AppleScripts that would take care of the task. I tweaked one around
a bit so that it would suit our environment. I've included the basic
template at the end of this message.
It first eliminates all current desktop printers (careful,
you might not want to do this in your case), then goes through and
sets up each of the printers. (I include only one printer below, but
it can be extended by duplicating that block of code.)
Note that it relies on knowing the hard drive's name; in most
cases, our users' machines' HDs are named 'Macintosh HD'. Also, the
script expects to find the PPDs for each printer it's setting up; if
it doesn't find the appropriate PPD buried down in the Extensions
folder, it will fail.
Hope this is useful to other folks as the abatement sweeps
across campus. I haven't done lots of AppleScripting, so the code
could probably be lots cleaner, but it seems to do the trick for us.
-Greg Merritt
Institute of Transportation Studies
-----------------------------------------------------------------------
-----------------------------------------------------------------------
try
tell application "Desktop Printer Manager"
-- Clear out old ones
delete (every desktop printer)
-- Set up HD name
set the HD_name to "bluejay"
-- Systems Unit printer
set the IP_address to "128.32.196.68"
set the DTP_name to "ITS-Systems Unit"
set the PPD_name to "HP LaserJet 5M"
set the PPD_file to ( the HD_name & ¬
(":System Folder:Extensions:Printer
Descriptions:" as text) & ¬
the PPD_name) as string as alias
set the printer_driver to "LaserWriter 8"
-- Now do it, create the printer with a call to the DPM
try
set my_printer to make new desktop printer at
desktop with properties ¬
{name:the DTP_name, is default:true ¬
, PPD file:the PPD_file ¬
, shows manual feed alert:false ¬
, address:{class:address
specification ¬
, ID:the IP_address, protocol:IP} ¬
, driver name:the printer_driver}
on error the error_message number the error_number
if the error_number is not 128 then error the
error_message
end try
set the PPD file of the default printer to the PPD_file
end tell
on error the error_message
display dialog the error_message buttons {"OK"} default button 1
end try
-----------------------------------------------------------------------
-----------------------------------------------------------------------
------------------------------------------------------------------------
The following was automatically added to this message by the list server:
For information about MAGNet, its meetings and events, and its
mailing list, including information on subscribing and unsubscribing,
see the MAGNet Web site at <http://magnet.berkeley.edu/>.
This archive was generated by hypermail 2.1.5 : Thu Dec 05 2002 - 16:26:57 PST