0

我正在尝试运行以下脚本:

on run proUrl
    tell application "Safari"
        make new document with properties {URL:proUrl}
    end tell
end run

这就是我尝试运行它的方式:osascript script.scpt http://google.com.
我收到以下错误:如果我将变量
script.scpt: execution error: Safari got an error: AppleEvent handler failed. (-10000)
替换为然后它可以工作。proUrl"http://google.com"

我怎样才能解决这个问题?

4

2 回答 2

1

proUrl 是一个项目列表,即使只有一项您要发送到 applescript。所以实际的 url 是“proURL 的第 1 项”。这就是我将如何编写您的脚本...

on run proUrlList
    open location (item 1 of proUrlList)
end run
于 2013-07-20T20:47:59.663 回答
1

要从命令行在默认浏览器中打开 URL,只需使用open

open http://google.com

查看man open更多。

于 2013-07-22T13:41:52.573 回答