Printer migration

jarednichols
Honored Contributor

Hi-

We've potentially got a printer migration from one type of multi-function unit to another (Ricoh to a Konica Minolta). I'm actually quite pleased with the Konica selection as it appears to be a good unit and has good Mac drivers. Adding this one is not a problem. What I'm really looking for is a way to see what people have for printers and if they have a particular one, remove it and add the Konica. We currently collect printer info in the inventory options, but I don't see a good way to search on that info (e.g. Make a smart group for a particular printer name or printer IP address).

Anyone have ideas for this one? I could always make an Extension Attribute, but I've already got the information collected, I'd like to use it if possible.

Thanks!
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

3 REPLIES 3

jarednichols
Honored Contributor

Hi-

Witness one of my most awesome shell scripts like ever ever:

#!/bin/sh

# This script does pattern matching on installed printers for any command line arguements give to
# search upon. It then deletes the matched printer

while [ "$*" != "" ] ; do
deletePrinter=lpstat -v | sed -e 's/device for //' | grep -i $1 | cut -d ":" -f 1 ; shift
done

lpadmin -x $deletePrinter

Basically, you can give this script as many arguments as you want (either totally manually, fired off with a Casper policy or with Casper Remote), it'll cycle through them, and if it finds a match, delete that printer.

Tough nut, 4 lines of code. 2 of which are for looping. Gotta pat myself on the back for this one.
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

bentoms
Release Candidate Programs Tester

Jared,

This looks almost perfect for something I need to do Monday.

But I'm failing miserably with sending a variable to tell the script what printer to delete, in fact I think I may need a for loop or something as I want to remove all printers that have lpd://10.44.112.* etc..

Help would be greatly appreciated

Regards,
Ben Toms
IT Support Analyst GREY Group
The Johnson Building, 77 Hatton Garden, London, EC1N 8JS
T: +44 (0) 20-3037-3819 |
Main: +44 (0) 20 3037 3000 | IT Helpdesk: +44 (0) 20 3037 3883

Not applicable

Ben,

Can't say I've had the opportunity to play with extension attributes just yet but I have a loop for adding printers that could be changed to remove them.

#!/bin/sh

lpstat -v | grep -i ksmb | awk -F " " '{print $4}' > deletetest.txt

while read inputline
do printer=(echo inputline | cut -d/ -f4) `lpadmin -x $printer`
done < deletetest.txt

Seems to work without incident in my limited testing. Just change the grep to whatever protocol you're looking to nuke.

Regards

Rhys