private int execScript(List<String> cmds, boolean captureOutandErr) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
MutableMap<String,?> flags = (captureOutandErr) ? MutableMap.of("out", out, "err", err) : MutableMap.<String,Object>of();
tool = newSshTool(MutableMap.of("host", "localhost"));
tool.connect();
int result = tool.execScript(flags, cmds);
tool.disconnect();
int outlen = out.toByteArray().length;
int errlen = out.toByteArray().length;
if (LOG.isTraceEnabled()) LOG.trace("Executed: result={}; stdout={}; stderr={}", new Object[] {result, outlen, errlen});
return result;
}
}