Applescript"预计行结束但找到标识符"对于终端应用程序

时间:2016-09-10 19:50:07

标签: applescript

此处为applescript完成noob。我想知道如何解决下面显示的applescript的以下问题:

我在第tell the current terminal行上收到以下错误:

enter image description here

Expected end of line but identifier found

enter image description here

以下是希望试用的人的代码:

tell application "iTerm"
    make new terminal
    tell the current terminal
        activate current session
        launch session "Default Session"
        tell the last session
            write text "unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH"
            write text "mkdir -p ~/.boot2docker"
            write text "if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi"
            write text "/usr/local/bin/boot2docker init && /usr/local/bin/boot2docker up && $(boot2docker shellinit) && docker version"
        end tell
    end tell
end tell

参考:https://apple.stackexchange.com/questions/8299/how-do-i-make-an-applescript-file-into-a-mac-app

1 个答案:

答案 0 :(得分:2)

因为terminal字词是旧的 AppleScript 语法。

查看https://www.iterm2.com/documentation-scripting.html以获取新的Applescript语法。

tell application "iTerm"
    activate
    set newWindow to (create window with default profile)
    tell newWindow
        tell current session
            write text "unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH"
            write text "mkdir -p ~/.boot2docker"
            write text "if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi"
            write text "/usr/local/bin/boot2docker init && /usr/local/bin/boot2docker up && $(boot2docker shellinit) && docker version"
        end tell
    end tell
end tell