通过EPPC显示远程机器的对话框

时间:2012-07-16 23:22:20

标签: macos applescript

如何通过EPPC将显示对话框发送到远程机器?我相信发行说明中的​​Scripting Addition Security讨论了这个问题,但我还没有解决它。 Release Notes

尝试1

using terms from application "Finder"
    set remoteFinder to application "Finder" of machine "eppc://user:password@host"
    tell remoteFinder to display dialog "Hi!" buttons {"A", "B"}
end using terms from

enter image description here

尝试2 应用程序“dispD.app”保存在远程计算机上,应接受yourMessage参数。

on run {yourMessage}
    display dialog yourMessage buttons {"A", "B"}
end run

我从本地计算机运行此脚本:

using terms from application "Finder"
    set remoteFinder to application "Finder" of machine "eppc://user:password@host"
    tell remoteFinder to run script file "path:to:my:dispD.app" with parameters {"Hi!"}
end using terms from

enter image description here

1 个答案:

答案 0 :(得分:1)

我认为你想要做的事情可能是不可能直接做的,虽然很难找到这方面的文件,但我并不是百分之百确定。 MacScripter上的各种线程(例如this one)和Apple论坛上的各种线程表明,与EPPC相比,OSAXen(“Scripting Additions”)存在各种问题。 (线程有点令人困惑,因为它们都分为红色鲱鱼,但我认为其中一些有相关信息。)而“显示对话框”命令不是Finder(或系统事件)的一部分,它是StandardAdditions OSAX。

这实际上很难在AppleScript中进行测试,因为OSAX的添加是自动引入的。但是从appscript中,您可以手动将OSAX附加到这样的应用程序:

sa = osax.ScriptingAddition('StandardAdditions', name='Finder')
sa.display_dialog('hi')

正如所料,这是有效的。虽然这给出了“未知的属性,元素或命令”:

f = app(name='Finder')
f.display_dialog('hi')

现在,如果我执行一个实际的Finder命令,就像这样:

f.windows()

一切正常。如果我想远程:

rf = app(url='eppc://test:test@localhost/Finder')
rf.windows()

没问题。但现在:

sa = osax.ScriptingAddition('StandardAdditions', url='eppc://test:test@localhost/Finder')
sa.display_dialog('hi')

这适用于10.5,但不适用于10.6,10.7或10.8。 (好吧,在我可以访问的8台机器中,它适用于运行10.5的机器,但不适用于运行10.6 +的7台机器。)

所以,我认为这是你的问题。

至于解决方案,我可以想到几个方法:

  • 不使用远程脚本,而是使用ssh + local osascript。
  • 使用cocoadialog,pashua等,并使用do shell script驱动它们,而不是使用display dialog。 (这将要求您在远程目标计算机上使用相应的工具,而不是本地计算机。)
  • 远程脚本可以本地显示对话框的应用程序,而不是依赖于StandardAdditions。 (我不知道是否有任何股票应用程序有任何办法,所以这可能需要在远程机器上安装一些东西,在这种情况下你也可以只使用cocoadialog。)
相关问题