G’day all, and thanks for an answer Ron.
Unfortunately on my iMac the ‘column’ number appears to be different, $31, so that leads me to suspect that the column will be different for different printers. That knowledge has resulted in my using parsing, so my script becomes…
use AppleScript version "2.3.1" use scripting additions use framework "Foundation" use framework "AppKit"
on run setPrinter() end run
on setPrinter() set printerAcceptingProperties to do shell script ("lpoptions -d Quark_Printer| awk '{print $31}’") # <— on my iMac
set offsetString to "printer-is-accepting-jobs=" as text set defaultPrinterProperties to do shell script ("lpoptions -d Quark_Printer") set theOffset to offset of offsetString in defaultPrinterProperties set acceptingJobs to characters (theOffset + (count of offsetString)) thru (theOffset + (count of offsetString) + 3) of defaultPrinterProperties as text if acceptingJobs is "true" then display dialog "Quark_Printer is accepting Jobs" defaultPrinterProperties & return & return & acceptingJobs end setPrinter
Result of Main Script: --> "copies=1 device-uri= dnssd://HP LaserJet 200 color M251nw (4C7452)._ipp._tcp.local. finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=1412906605 marker-colors=#00FFFF,#FF00FF,#FFFF00,#000000 marker-high-levels=100,100,100,100 marker-levels=100,96,100,87 marker-low-levels=6,6,6,7 marker-names='Cyan\\ Cartridge\\ HP\\ CF211A,Magenta\\ Cartridge\\ HP\\ CF213A,Yellow\\ Cartridge\\ HP\\ CF212A,Black\\ Cartridge\\ HP\\ CF210X' marker-types=toner,toner,toner,toner number-up=1 printer-commands=AutoConfigure,Clean,PrintSelfTestPage printer-info='Quark Printer' printer-is-accepting-jobs=true printer-is-shared=false printer-location printer-make-and-model='HP LaserJet 200 color M251nw-AirPrint' printer-state=5 printer-state-change-time=1414115093 printer-state-reasons=none printer-type=10522828 printer-uri-supported= ipp://localhost/printers/Quark_Printer
true"
On 24 Oct 2014, at 12:38 am, Ron Reuter < email@hidden> wrote: Well, it's not pretty, but since you've already dirtied your hands with do shell script :-), why not continue in that vein... You can pipe the results to awk, and by providing the correct "column number", filter out the chunk of text you need. Hopefully someone will have a better answer.
lpoptions -p Photosmart_C4700_series | awk '{print $35}'
==> printer-is-accepting-jobs=true
On 23 Oct 2014, at 5:56 AM, Brian Christmas < email@hidden> wrote: G’day
I’ve worked out through googling how to set my default printer on Yosemite, but I’d like to be able to check if the printer is actually accepting jobs. The information is listed in the shell scripts returned data, but I can’t find a way to retrieve the setting as a property. Is such a thing possible, or should I parse the data to check for true? Parsing seems such an awkward method.
Regards
Santa
|