调用“open”时出现错误代码-10810来自苹果脚本

发布于 2024-10-19 02:17:59 字数 603 浏览 2 评论 0原文

我正在尝试使用 AppleScript 修改某些应用程序设置。代码如下所示:

#!/bin/sh

echo '
 tell application "Finder"
   tell disk "'$1'"
       open
       set current view of container window to icon view
       ...
       close
   end tell
end tell
' | osascript

但是,当 applescript 点击“打开”时,我不断收到 -10810 错误代码(“64:68:执行错误:发生了 -10810 类型的错误。(-10810)”)。我已经做了一些谷歌搜索,我得到的只是“重新启动并等待,它有时会神奇地开始工作”(它没有)。

该计算机正在运行 Mac OS Server 10.6。我认为这可能是一些权限问题,但以 root 身份运行命令会返回相同的错误。

更新:已解决(好吧,或多或少:-))。问题是“开放”需要一个用户界面。问题是我使用 ssh 来运行脚本(我在这里没有提到,因为我认为它不相关)。所以没有用户界面。当我首先使用 VNC 登录时它可以工作。

I'm trying to use AppleScript to modify some app settings. The code looks like this:

#!/bin/sh

echo '
 tell application "Finder"
   tell disk "'$1'"
       open
       set current view of container window to icon view
       ...
       close
   end tell
end tell
' | osascript

However, I keep on getting a -10810 error code when applescript hits "open" ("64:68: execution error: An error of type -10810 has occurred. (-10810)"). I've done some googling and all I got was "reboot and wait, it sometimes magically starts working" (it didn't).

The machine is running Mac OS Server 10.6. I though it perhaps might be some permissions issue, but running the command as root returns the same error.

Update: Solved (well, more or less :-) ). The thing is that "open" needs a UI. And the problem was that I was using ssh to run the script (which I didn't mention here, because I didn't think it was relevant). So there was no UI. It works when I log in using VNC first.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天白云 2024-10-26 02:17:59

解决了(好吧,或多或少:-))。

问题是“开放”需要一个用户界面。问题是我使用 ssh 来运行脚本(我在这里没有提到,因为我认为它不相关)。所以没有用户界面。当我首先使用 VNC 登录时它可以工作。

Solved (well, more or less :-) ).

The thing is that "open" needs a UI. And the problem was that I was using ssh to run the script (which I didn't mention here, because I didn't think it was relevant). So there was no UI. It works when I log in using VNC first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文