while(!baos.toString().contains("000")){// cannot just search for, say, "groovy:000> " since there are ANSI escapes there (cf. StringEscapeUtils.escapeJava)
Thread.sleep(100);
}
pw.println("11 * 11");
while(!baos.toString().contains("121")){// ditto not "===> 121"