public Result executeCommand(final String cmd) throws Exception { int exitCode = 0; Exception lastException = null; ByteArrayOutputStream bao = new ByteArrayOutputStream(); PrintStream origOut = System.out; PrintStream origErr = System.err; System.setOut(new PrintStream(bao)); System.setErr(new PrintStream(bao)); try { execute(cmd); } catch (Exception e) { e.printStackTrace(); lastException = e; exitCode = -1; } finally { System.setOut(origOut); System.setErr(origErr); } return new Result(bao.toString(), exitCode, lastException, cmd); }
public Result executeCommand(final String cmd) throws Exception { int exitCode = 0; Exception lastException = null; ByteArrayOutputStream bao = new ByteArrayOutputStream(); PrintStream origOut = System.out; PrintStream origErr = System.err; System.setOut(new PrintStream(bao)); System.setErr(new PrintStream(bao)); try { execute(cmd); } catch (Exception e) { e.printStackTrace(); lastException = e; exitCode = -1; } finally { System.setOut(origOut); System.setErr(origErr); } return new Result(bao.toString(), exitCode, lastException, cmd); }
public Result executeCommand(final String cmd) throws Exception { int exitCode = 0; Exception lastException = null; ByteArrayOutputStream bao = new ByteArrayOutputStream(); PrintStream origOut = System.out; PrintStream origErr = System.err; System.setOut(new PrintStream(bao)); System.setErr(new PrintStream(bao)); try { execute(cmd); } catch (Exception e) { e.printStackTrace(); lastException = e; exitCode = -1; } finally { System.setOut(origOut); System.setErr(origErr); } return new Result(bao.toString(), exitCode, lastException, cmd); }