<p>Groovy adds the <code>execute</code> method to <code>String</code> to make executing shells fairly easy;</p>

<pre><code>println "ls".execute().text
</code></pre>

<p>but if an error happens, then there is no resulting output.  <strong>Is there an easy way to get both the standard error and standard out?</strong>  (other than creating a bunch of code to; create two threads to read both inputstreams, then using a parent stream to wait for them to complete then convert the strings back to text?)</p>

<p>It would be nice to have something like;</p>

<pre><code> def x = shellDo("ls /tmp/NoFile")
 println "out: ${x.out} err:${x.err}"
</code></pre>

```
"ls".execute()
```
returns a
```
Process
```
object which is why
```
"ls".execute().text
```
works. You should be able to just read the error stream to determine if there were any errors.
There is a extra method on
```
Process
```
that allow you to pass a
```
StringBuffer
```
to retrieve the text:
```
consumeProcessErrorStream(StringBuffer error)
```
.
Example:
```
```
def proc = "ls".execute()
def b = new StringBuffer()
proc.consumeProcessErrorStream(b)

println proc.text
println b.toString()
```
```