Looking for specific output

I am trying to create a macro that once started monitors an iterm screen for specific output and after seeing it executes the next macro item. Is this possible?

Hey Shawn,

Well, there’s monitoring and there’s monitoring.

It may or may not be possible to write a shell script to run your process that monitors in real-time, but that’s beyond me at present.

However. You can periodically check the contents of the iTerm session and parse for your string.

tell application "iTerm"
  tell the first terminal
    tell the last session
      set iTermSessionOutPut to its text
    end tell
  end tell
end tell

-Chris

An example would be:

do something

wait for prompt: <-- when you see the prompt

copy the next command etc…

Hey Shawn,

Please be more specific.

You can’t test for the prompt.

As I’ve said you can get the text of the session and parse it looking for the bare prompt at the end.

But this seems more like a task for a little shell scripting.

iTerm doesn’t have a busy property like Termainal.app, but something like this might work.

tell application "iTerm"
  tell current session of front terminal
    if name = "bash" then
      true
    else
      false
    end if
  end tell
end tell

-Chris