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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With