Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wait for command line program execution before issuing new action in AppleScript

Tags:

applescript

I am pretty new to AppleScript. I need a script that opens 3 iTerm tabs and executes 3 command line programs respectively. The first program terminates, while the last 2 run indeterminately.

Here is what I have:

tell application "iTerm"
    activate
    set next to (make new terminal)
    tell next
        activate current session
        launch session "Default Session"
        tell the last session
            set name to "vagrant-db"
            write text "cd ~/Workspace/vagrant-db; vagrant up"
        end tell

        launch session "Default Session"
        tell the last session
            set name to "next/core"
            write text "cd ~/Workspace/next"
            write text "/usr/local/bin/sbt \"project core\" \"run\""
        end tell

        launch session "Default Session"
        tell the last session
            set name to "next/web"
            write text "cd ~/Workspace/next"
            write text "/usr/local/bin/sbt \"project web\" \"~re-start\""
        end tell

    end tell
end tell

Problem is I need to wait for the first command line operation to end (vagrant booting up) before issuing the second and third. Is there a way to do it?

like image 644
fusio Avatar asked Dec 01 '25 02:12

fusio


1 Answers

Not sure if it is possible, but maybe using "do shell script" command from applescript instead, e.g.

set response to do shell script "ls"

will return the contents of the root folder.

Another way (but a very ugly one) is to use 'delay'. E.g.

delay 5

Will delay for 5 seconds

like image 187
Rusty Avatar answered Dec 04 '25 00:12

Rusty