title: wait for command line program execution before issuing new action in AppleScript
body: <p>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.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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? </p>