• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is there an easier way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there an easier way?


  • Subject: Re: Is there an easier way?
  • From: Brian Christmas <email@hidden>
  • Date: Fri, 05 Dec 2014 06:51:04 +1100

Thanks Stan, but there appears to be something wrong with your last shell script. (it’s 6:49 am in Oz, and I’ve been up all night, so I hope my code is correct).

I was already using the -a option to get a list of printers, but page lists have eluded me, especially when there are many secondary paper menus on my two printers when using text edit (like ‘A4 without margins').

My code as below returns gobbledygook, and if I uncomment the last line, I get an error. Are you aware of any problems?

Regards

Santa

set wholePrinterList to item 1 of ((do shell script "lpstat -a") & return as list)
set findCharacter to (character id 13)
set printerList to "No Printer Selected" & return as text
set printerList to ""
if (count of wholePrinterList) > 0 then
repeat
set nameOfEachPrinter to characters 1 through ((offset of " " in (wholePrinterList as text)) - 1) of (wholePrinterList as text) as text
set printerList to printerList & nameOfEachPrinter & return
set theNextReturn to offset of findCharacter in (wholePrinterList as text)
if theNextReturn < (count of wholePrinterList) then
set wholePrinterList to characters (theNextReturn + 1) through (count of wholePrinterList) of (wholePrinterList as text) as text
else
exit repeat
end if
end repeat
end if
set pageLists to ""
repeat with x from 1 to (count of printerList)
set eachPrinter to item x of printerList as text
set pageLists to pageLists & (do shell script "lpoptions -p " & eachPrinter & " -p" & return & return)
end repeat

printerList & return & return & pageLists

#do shell script "lpoptions -p EPSON_Artisan_730 -p”

returns…

"EPSON_Artisan_730
Quark_Printer
rtfd_Printer


ËsmˇË>tnˇË~C`ˇËlˇËN≤nˇËbˇËÉjˇË>ÅmˇËû¢dˇËû¿jˇË.∂hˇËÓ¶cˇËnSoˇËŒ‚bˇËû%cˇËé˚iˇËƘbˇËÓıaˇËfi£jˇËfi.dˇË>πiˇËbˇËæË^fijˇËÓ°dˇË£nˇËNŸnˇËÍgˇËæÑfˇËìgˇËûrfˇË^ªkˇ˲£iˇ˲Òfˇ˲ÑmˇËŒíkˇ˲lhˇËn§cˇËÓfljˇËûdˇËŒfdˇËŒonˇËŒ=aˇËfi/kˇË.ådˇ”

Uncomment the last line, and this error occurs…

error "Usage: lpoptions [-h server] [-E] -d printer
       lpoptions [-h server] [-E] [-p printer] -l
       lpoptions [-h server] [-E] -p printer -o option[=value] ...
       lpoptions [-h server] [-E] -x printer" number 1


On 5 Dec 2014, at 5:04 am, Stan Cleveland <email@hidden> wrote:

On Dec 4, 2014, at 7:36 AM, Brian Christmas <email@hidden> wrote:

I’m trying to build a list of every paper size available to any given printer, set from a printer list of existing printers.

I’m using the print dialog box from Text Edit, with the code below.

It’s very slow, so I’m wondering if there’s any way of obtaining the list without opening every paper menu?

Any help appreciated.

Hi Brian,

You could use 'do shell script' and parse the text returned by the following two shell commands.

This gives you a listing of "Unix" names for every printer set up on your computer:

lpstat -p

This lists all printer options, including paper sizes. Put your "Unix" printer name in place of mine, in red:

lpoptions -p Canon_iR_ADV_C9000s_A1_PSV1_0US -p

Below is the PageSize/Media Size portion of the result of the latter command on my system. It's all in one line. The Custom.WIDTHxHEIGHT entry indicates that custom page sizes are supported. The page size that's preceded by an asterisk is the default page size.

PageSize/Media Size: Custom.WIDTHxHEIGHT *Letter Legal Tabloid Executive Statement A3 A4 A5 B5 B4 Monarch Com10 DL C5 ISOB5 SRA3 12x18 13x19 13x19_MAX

HTH,
Stan C.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Is there an easier way?
      • From: Stan Cleveland <email@hidden>
References: 
 >Is there an easier way? (From: Brian Christmas <email@hidden>)
 >Re: Is there an easier way? (From: Stan Cleveland <email@hidden>)

  • Prev by Date: Re: Is there an easier way?
  • Next by Date: Re: Is there an easier way?
  • Previous by thread: Re: Is there an easier way?
  • Next by thread: Re: Is there an easier way?
  • Index(es):
    • Date
    • Thread