public int execute() throws Exception { try { Process executor = Runtime.getRuntime().exec(cmd); StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, out); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, err); outPrinter.start(); errPrinter.start(); int ret = executor.waitFor(); outPrinter.join(); errPrinter.join(); return ret; } catch (IOException ex) { throw new Exception("Failed to execute " + cmd, ex); } }
StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, System.out); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, errPrintStream); outPrinter.start(); errPrinter.start(); outPrinter.join(); errPrinter.join();
OperationLog operationLog = OperationLog.getCurrentOperationLog(); if (operationLog != null) { outPrinter = new StreamPrinter(executor.getInputStream(), null, System.out, operationLog.getPrintStream()); errPrinter = new StreamPrinter(executor.getErrorStream(), null, errPrintStream, operationLog.getPrintStream()); } else { outPrinter = new StreamPrinter(executor.getInputStream(), null, System.out); errPrinter = new StreamPrinter(executor.getErrorStream(), null, errPrintStream); outPrinter.start(); errPrinter.start(); outPrinter.join(); errPrinter.join();
new CachingPrintStream(SessionState.getConsole().getChildErrStream()); StreamPrinter outPrinter = new StreamPrinter( executor.getInputStream(), null, SessionState.getConsole().getChildOutStream()); StreamPrinter errPrinter = new StreamPrinter( executor.getErrorStream(), null, errPrintStream); outPrinter.start(); errPrinter.start(); outPrinter.join(); errPrinter.join();
new CachingPrintStream(SessionState.getConsole().getChildErrStream()); StreamPrinter outPrinter = new StreamPrinter( executor.getInputStream(), null, SessionState.getConsole().getChildOutStream()); StreamPrinter errPrinter = new StreamPrinter( executor.getErrorStream(), null, errPrintStream); outPrinter.start(); errPrinter.start(); outPrinter.join(); errPrinter.join();
private static QTestProcessExecResult executeCmd(String[] args, String outFile, String errFile) throws Exception { System.out.println("Running: " + org.apache.commons.lang.StringUtils.join(args, ' ')); PrintStream out = outFile == null ? SessionState.getConsole().getChildOutStream() : new PrintStream(new FileOutputStream(outFile), true, "UTF-8"); PrintStream err = errFile == null ? SessionState.getConsole().getChildErrStream() : new PrintStream(new FileOutputStream(errFile), true, "UTF-8"); Process executor = Runtime.getRuntime().exec(args); ByteArrayOutputStream bos = new ByteArrayOutputStream(); PrintStream str = new PrintStream(bos, true, "UTF-8"); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, err); StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, out, str); outPrinter.start(); errPrinter.start(); int result = executor.waitFor(); outPrinter.join(); errPrinter.join(); if (outFile != null) { out.close(); } if (errFile != null) { err.close(); } return QTestProcessExecResult. create(result, new String(bos.toByteArray(), StandardCharsets.UTF_8)); }
public int execute() throws Exception { try { Process executor = Runtime.getRuntime().exec(cmd); StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, out); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, err); outPrinter.start(); errPrinter.start(); int ret = executor.waitFor(); outPrinter.join(); errPrinter.join(); return ret; } catch (IOException ex) { throw new Exception("Failed to execute " + cmd, ex); } }
public int execute() throws Exception { try { Process executor = Runtime.getRuntime().exec(cmd); StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, out); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, err); outPrinter.start(); errPrinter.start(); int ret = executor.waitFor(); outPrinter.join(); errPrinter.join(); return ret; } catch (IOException ex) { throw new Exception("Failed to execute " + cmd, ex); } }
StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, System.out); StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, errPrintStream); outPrinter.start(); errPrinter.start(); outPrinter.join(); errPrinter.join();
new CachingPrintStream(SessionState.getConsole().getChildErrStream()); StreamPrinter outPrinter = new StreamPrinter( executor.getInputStream(), null, SessionState.getConsole().getChildOutStream()); StreamPrinter errPrinter = new StreamPrinter( executor.getErrorStream(), null, errPrintStream); outPrinter.start(); errPrinter.start(); outPrinter.join(); errPrinter.join();