1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Remote AppleScript failing

Discussion in 'iTunes & AppleScripts' started by someToast, Jul 12, 2016.

  1. someToast

    someToast Member

    I have a script that’s worked for years that talks to iTunes on another Mac on the local network. Today, it started failing.

    Even a one-line activate script:
    tell application "iTunes" of machine "eppc://username:password@27-iMac.local" to activate
    Returns the error in Script Editor of “Syntax Error Application isn’t running” (it is) and in the Console:
    7/11/16 7:26:19.206 PM Script Editor[937]: CFNetwork SSLHandshake failed (-9806)
    For fun, everything’s been restarted to no avail and I’m not finding anything AppleScript-related online that addresses this error.
  2. DougAdams

    DougAdams Moderator Staff Member

    Does this work:

    tell application "iTunes" of machine "eppc://user:password@Remote-Machine.local"
    	using terms from application "iTunes"
                    -- and so on
    	end using terms from
    end tell{/code]
  3. someToast

    someToast Member

    Unfortunately not — same errors in Script Editor and Console.

    I can SSH from the Terminal to the remote Mac and use osascript, but that won’t work for my application.

    ssh 27-iMac.local "osascript -e 'tell application \"iTunes\" to play'"
  4. someToast

    someToast Member

    As it turns out, this is systemic and remote AppleScript to any app on this computer fails with the SSLHandshake error.

    The Mac I’m trying to communicate with is my general media server with music, movies, and photos. Sunday night I had turned on iCloud Photo Library, starting the massive, multi-day photo upload. The AppleScript issue didn’t start at the exact same time, and it still happens if I pause the upload and restart the Mac, but it’s the only condition I can think of that’s changed recently on this Mac.
  5. DougAdams

    DougAdams Moderator Staff Member

    I assume that you checked and Sharing Preferences are in order.

    There was an issue 2-3 years ago with EPPC after a Security Update (subsequently fixed), but I'm not aware of anything like that currently. Unfortunately, my second computer is in the shop so I can't test this issue at all right now.
  6. someToast

    someToast Member

    Sharing prefs are all up and unchanged. The (since fixed) security update issue was the only thing related I came across while searching online.

    That CFNetwork SSLHandshake error showed up a lot for iOS developer questions, but I don’t know if/how that relates to networked Apple Events.
  7. DougAdams

    DougAdams Moderator Staff Member

    I was finally able to test this. I had no problems using eppc protocol between machines. I'm not exactly a wall of genius when it comes to remote scripting, so I couldn't say what to investigate next.
  8. someToast

    someToast Member

    Thanks for checking!

    That iCloud Photo Library upload finally finished, but if it was the catalyst, the damage is done, because communication still fails.

    Remote Apple Events in the opposite direction work — so it does point to an issue on the iMac. My next attempt (after yet another restart) will be doing a deeper dive on the iMac’s root certificates.
  9. someToast

    someToast Member

    I never did figure out why I can no longer send remote Apple Events from this Mac, but I did an end run around the issue by setting up key-based authentication for SSH and doing the whole thing in an osascript on the remote machine.

    The commented-out block was the old remote Apple Events method, and below it, the SSH method I have running now. Ugh, what a mess. I’ll revisit going back to remote events after eventually getting Sierra on both Macs.

    --tell application "iTunes" of machine "eppc://user:pass@27-iMac.local"
    --	try
    --		set trackRef to (add currentPath as POSIX file)
    --		tell trackRef
    --			set persistentID to get persistent ID
    --		end tell
    --	on error
    --		set persistentID to 0
    --	end try
    --end tell
    set theScript to "ssh user@27-iMac.local \"osascript -e 'tell app \\\"iTunes\\\"
    	set trackRef to (add \\\"" & currentPath & "\\\" as POSIX file)
    	tell trackRef
    		set persistentID to get persistent ID
    	end tell
    on error
    	set persistentID to 0
    end try
    end tell
    set persistentID to do shell script theScript

Share This Page