7 Replies Latest reply on Mar 13, 2017 3:17 PM by bertrand

    FM and AppleScript using CUPS (lp...) to get name of default printer

    bertrand

      Hello

       

      I've found some years ago a way to get printers list and change the default printer at FMSource in French, some scripts written by Clem.

       

      Now theese scripts don't work and I can guess what is the good way to do the same.

       

      I want to get in field z_MAC_SETTINGSGR::MAC_Printer_default the name of the default printer.

      With Terminal I can excecute : lpstat -d | awk 'BEGIN {FS=": "}{print $2}'

      which give : Deskjet_F4580

       

      In my script I do this : AppleScript Execute ( value : "set data of cell "z_MAC_SETTINGSGR::MAC_Printer_default"  to do shell script "lpstat -d | awk 'BEGIN {FS=\": \"}{print $2}'""

      wich give : set data of cell "z_MAC_SETTINGSGR::MAC_Printer_default"  to do shell script "lpstat -d | awk 'BEGIN {FS=\": \"}{print $2}'"

       

      I get a crash report :

      -------------------------------------------

      Process:               FileMaker Pro [90732]

      Path:                  /Applications/FileMaker Pro 15 Advanced/FileMaker Pro Advanced 15.app/Contents/MacOS/FileMaker Pro

      Identifier:            FileMaker Pro

      Version:               15.0.3 (15.0.3)

      Code Type:             X86-64 (Native)

      Parent Process:        FileMaker Pro [67667]

      Responsible:           FileMaker Pro [90732]

      User ID:               502

       

      Date/Time:             2017-03-12 09:31:04.706 +0100

      OS Version:            Mac OS X 10.12.4 (16E183b)

      Report Version:        12

      Anonymous UUID:        1BA161D3-CCFD-AD3E-E26D-3DFDE26C71F3

       

      Sleep/Wake UUID:       05DA7BA2-F3D8-4745-9410-0A7D87B152F6

       

      Time Awake Since Boot: 290000 seconds

      Time Since Wake:       140000 seconds

       

      System Integrity Protection: disabled

       

      Crashed Thread:        0  Dispatch queue: com.apple.main-thread

       

      Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)

      Exception Codes:       0x0000000000000001, 0x0000000000000000

      Exception Note:        EXC_CORPSE_NOTIFY

       

      Termination Signal:    Illegal instruction: 4

      Termination Reason:    Namespace SIGNAL, Code 0x4

      Terminating Process:   exc handler [0]

       

      Application Specific Information:

      BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock

       

      Thread 0 Crashed:: Dispatch queue: com.apple.main-thread

      0   libsystem_platform.dylib       0x0000000106be9ae4 _os_unfair_lock_recursive_abort + 23

      1   libsystem_platform.dylib       0x0000000106be9405 _os_unfair_lock_lock_slow + 181

      2   libobjc.A.dylib               0x00007fff8f6c8680 _object_remove_assocations + 74

      ........

      -------------------------------------------

       

      and and unknown error 1004 when using this command, I say Ok to crash report and my script continue running.

       

      Thanks for your help.