预期行尾等,但发现“脚本”

oct*_*ian 4 macos applescript iterm2

我编写了一个非常基本的苹果脚本,该脚本打开iTerm并转到文件:

\n\n
tell application "iTerm"\n    activate\n    do script "cd ~" in tab 1\nend tell\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是,如果我尝试运行它,我会得到Syntax Error

\n\n
Expected end of line, etc. but found \xe2\x80\x9cscript\xe2\x80\x9d.\n
Run Code Online (Sandbox Code Playgroud)\n\n

知道为什么会这样吗?

\n\n

该脚本中是否存在一些不正确的语法?

\n

oct*_*ian 5

是的,事实证明语法不正确。

这有效:

tell application "iTerm"
    create window with default profile
    tell current session of current window
        write text "cd ~"
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)