调用“open”时出现错误代码-10810来自苹果脚本
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了(好吧,或多或少:-))。
问题是“开放”需要一个用户界面。问题是我使用 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.