Assertions - Terminal Output

Is it possible to add assertions for a terminal output in AppleScript?
do script “osascript -e 'tell application “Terminal”
reopen
activate
delay 1
./ccwrap -c 2” in window 1
on idle

              end idle
              end tell'
              """)

Here is my code. I am entering a command and want to expect a certain output. I’ve seen that if statements would work for this but couldn’t quite figure out how to make it work.

A couple of questions and comments…

What is reopen? It is not an applescript command and it is also not a shell command that’s on my system.

What is ccwrap?

Your quote structure seems awry to me; single and double quotes are interleaved.

Finally, osascript has multiple means of taking applescript commands.

  1. Each applescript command is specified with an ‘-e’ switch, like so…
 osascript -e 'Tell application "Finder"' -e 'get selection as text' -e 'end tell'
  1. The script is placed in an applescript document — could be script or text (ie with extension of ‘scpt’ or ‘applescript’). In this example, it runs a script saved on the desktop.

osascript ~/Desktop/get-selection.applescript

  1. Using standard input

echo ‘Tell application “Finder”
get selection as text
end tell’ | osascript

  1. Using the shell’s heredoc (which is actually an example of using ‘stdin’)

osascript <<‘END’
heredoc> tell application “Finder”
heredoc> get selection as text
heredoc> end tell
heredoc> END

Are you talking about some kind of test suite for AppleScript?

Perhaps if you could explain exactly what you are trying to do or where your example code came from it could be straightened out - as it is it won’t run, and looks like a Terminal command running a shell script to run an AppleScript that is trying to do something with Terminal, followed by what looks like remnants from Python or maybe Swift.

There is also an empty idle handler in there, which is used in stay-open applications - is this something that is being converted from a different script or scripting language?

FWIW, the following is the definition of the reopen command from the AppleScript Language Guide (here).

Many applications also support the reopen command, which reactivates a running application or launches it if it isn’t running. If the application is already running, this command has the same effect as double-clicking the application icon in the Finder. Each application determines how it will implement the reopen command—some may perform their usual startup procedures, such as opening a new window, while others perform no additional operations.

That’s an odd one. It’s not listed among the commands.

Thanks for pointing that out.

Why would you run a shell script command that calls AppleScript from AppleScript???

Why not just

set theResuts to do shell script "./ccwrap -c 2"