Applescript - LPD Printer - editing DeviceURI in printers.conf

joshmac777
New Contributor II

Ok, I've hacked away for hours, but I just can't seem to finish an Applescript that I'm working on for our image.

I've managed to create the following:
- an Applescript that prompts for UserID, Password, Email and sets up an Outlook account

I'd like to do the following within the same script:
- take the UserID variable that was created above and edit the printers.conf file by changing the DeviceURI...

from (current file text in printers.conf in cups.DMG that is deployed):
lpd://EMPLOYEE@10.100.153.197

to:
lpd://{UserID}@10.100.153.197

Sorry if that's complicated. Hard to be concise. I've search the posts on JAMF, but not breaking through.

3 ACCEPTED SOLUTIONS

joshmac777
New Contributor II

Here's the example script, for reference
https://www.dropbox.com/s/qeq1s5xw593t5tw/Outlook%26Printer-Example.scpt

View solution in original post

sean
Valued Contributor

You can use the following shell command:

lpadmin -v lpd://{UserID}@10.100.153.197 -d [Printer Queue Name]

View solution in original post

joshmac777
New Contributor II

Nevermind, seems that I got it. For some reason, I have to run the following, twice, to get the Duplex option triggered...

do shell script "/usr/sbin/lpadmin -p Company_SecurePrint -E -v lpd://E123456@10.100.153.197/secureprint -E -D "Company SecurePrint" -m drv:///sample.drv/generic.ppd -o Duplex=DuplexTumble -o Option1=True"

View solution in original post

12 REPLIES 12

joshmac777
New Contributor II

Here's the example script, for reference
https://www.dropbox.com/s/qeq1s5xw593t5tw/Outlook%26Printer-Example.scpt

joshmac777
New Contributor II

Here's the example script, for reference
https://www.dropbox.com/s/qeq1s5xw593t5tw/Outlook%26Printer-Example.scpt

joshmac777
New Contributor II

Sorry, double post for some reason

bentoms
Release Candidate Programs Tester

We use an AppleScript app @ login to mount drives & printers.

Not sure if it'll help, but linking just incase it does:

http://macmule.com/2011/09/08/how-to-map-drives-printers-based-on-ad-group-membership-on-osx/

joshmac777
New Contributor II

Thanks bentoms.

I think just switching out the text should do the trick, but applescript text replacement is proving to be a pain as I hack away.

joshmac777
New Contributor II

I'm at a bit of a loss. The printer is set up in the advanced tab (being an LPD setup) of Sys Prefs.

So, scripting the manual setup via "AddPrinter" just wasn't working.

Then, I switched to the idea of dropping the printers.conf file in by DMG and editing that. But, it's proving to be a pain.

talkingmoose
Moderator
Moderator

I took a quick look at what you're wanting to do and see a stumbling block.

The script is going to run under the current user's credentials and his privileges but I'm finding the /private/etc/cups/printers.conf file isn't even readble by the Standard user.

Not sure what you're referring to by "cups.DMG". Where's that coming into play?

sean
Valued Contributor

You can use the following shell command:

lpadmin -v lpd://{UserID}@10.100.153.197 -d [Printer Queue Name]

joshmac777
New Contributor II

Thanks all. Yeah, passing the variable into lpadmin looks good.

Just gotta find the right Generic postscript driver now.

Seeing this one in the PPD... *PPD-Adobe: "4.0"

Default "drv:///sample.drv/Generic.ppd" doesn't work with our duplex system.

joshmac777
New Contributor II

Or, at least, for whatever reason, I can't seem to get the option triggered to select "Duplexer" in the options, using the default generic driver.

joshmac777
New Contributor II

Using the "-o" option, I've triggered:
Duplex/2-Sided Printing: None *DuplexNoTumble DuplexTumble
Option1/Duplexer: False *True

But, still no dice. Alas. Still hammering away.

joshmac777
New Contributor II

Nevermind, seems that I got it. For some reason, I have to run the following, twice, to get the Duplex option triggered...

do shell script "/usr/sbin/lpadmin -p Company_SecurePrint -E -v lpd://E123456@10.100.153.197/secureprint -E -D "Company SecurePrint" -m drv:///sample.drv/generic.ppd -o Duplex=DuplexTumble -o Option1=True"