2
votes

Complete noob here for applescript. I am wondering how to resolve following problem for the applescript shown below:

I get the following error on the line tell the current terminal:

enter image description here

Expected end of line but identifier found

enter image description here

Here is the code for anyone wishing to try it out:

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

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

1

1 Answers

3
votes

Because the terminal term is an old AppleScript syntax.

Look at https://www.iterm2.com/documentation-scripting.html for the new Applescript syntax.

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