Applescript fails with error (-600) when launched over ssh on Mavericks

风流意气都作罢 提交于 2019-11-27 20:32:21

Application isn’t running(-600) is an operating system error.

An operating system error is an error that occurs when AppleScript or an application requests services from the Mac OS. They are rare, and often there is nothing you can do about them in a script, other than report them.

Arrrrgh! I don't want this to be the answer, but after trying just about everything, this now seems to be working after a restart.... My guess is that something in appleeventsd got confused (although restarting just appleeventsd on its own didn't fix anything). After a restart osascript seems to be behaving again. I'm still not convinced this is fully fixed, but it does seem to be working for the moment...

Jordan

For me, it was Apple Entitlements in Xcode.

Specifically,

com.apple.security.temporary-exception.apple-events

Set it as an Array

Then add two items to it.

com.apple.finder

com.apple.iTunes

See: My applescript doesn't work any more when I upgrade my OS X to 10.9

Apple Script is not the issue.

Enable access for assistive devices and applications by opening System Preferences > Security & Privacy > Privacy > Accessibility and check the applications you want to allow access.

More info: https://support.apple.com/en-us/HT202866

Jacob Salmela also has created a utility to do this from command line:

http://jacobsalmela.com/os-x-yosemite-enable-access-assistive-devices-command-line/

System Events is a really finicky asshat component of OS X. Here is my method for getting around that dreaded "Application isn't running -600" error:

set app_name to "System Events"
set the_pid to (do shell script "ps ax | grep " & (quoted form of app_name) & "$
if the_pid is not "" then do shell script ("kill -9 " & the_pid)

tell application "System Events"
-- activate  
end tell

I kill "System Events" with a kill -9 and then relaunch it.

@benmarbles code seems to be missing something at the end of line 2 -- it won't even compile.

Anyhow, I've seen the same issue with "Image Events" and I solved it with a simplified version of that script. Here's how I handle it:

tell application "System Events" to set thePID to (unix id of process "Image Events")
set killCMD to ("kill -9 " & thePID) as text
do shell script killCMD with administrator privileges

Replace Image Events with System Events to kill that process instead. The System Events process keeps itself alive, so there's no need to do anything to relaunch it.

S.Doe_Dude

I got the same error when I was unable to do GUI Scripts, but changing the System Preferences > Security & Privacy > Privacy > Accessibility settings for that specific app and adding a delay 0.5 between each line corrected it!

I was confused by this message "for System Events" not working in newer versions of Mac OS X from the command line:

osascript -e 'tell application "System Events" to display dialog "Build finished"'

It turns out the syntax of Applescript is (changed to?) just:

osascript -e 'display dialog "Build finished"'

for me this happened when I tried to open gitk. Changing back to the branch I was on before, and gitk was able to open again

Hello from 2k19 :) The approach below has helped to me

tell app "app_name"
    launch
    delay 2
end tell
tell app "app_name"
    do something usefull
end tell

or

osascript -e "tell app \"app_name\"" -e "launch" -e "delay 2"-e "end tell" -e "tell app \"app_name\"" -e "do someting usefull" - e "end tell"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!