I want it to check how many errors I got, from compiling that script.
You will need to write code that reads the compiler's output and extract from it the data you want.

Note the setErr method directs what is written to the err stream to a PrintStream which can be directed to a ByteArrayOutputStream that can be used to create a String.