logger.fine("Error while executing ssh-keygen: " + ex.getMessage());
private void waitForever() throws InterruptedException, ProcessManagerException { if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } process.waitFor(); }
public static void main(String[] args) { try { if (args.length <= 0) { System.out.println("Usage: ProcessManager cmd arg1 arg2 ... argn"); System.exit(1); } List<String> cmds = new ArrayList<String>(); for (int i = 0; i < args.length; i++) { cmds.add(args[i]); } ProcessManager pm = new ProcessManager(cmds); pm.execute(); System.out.println("*********** STDOUT ***********\n" + pm.getStdout()); System.out.println("*********** STDERR ***********\n" + pm.getStderr()); System.out.println("*********** EXIT VALUE: " + pm.getExitValue()); } catch (ProcessManagerException pme) { pme.printStackTrace(); } } ////////////////////////////////////////////////////////////////////////////
public static NadminReturn cmdWithOutput(final File cmd, final int timeout, final String... args) { List<String> command = new ArrayList<String>(); command.add(cmd.toString()); command.add("--echo"); command.addAll(Arrays.asList(args)); ProcessManager pm = new ProcessManager(command); // the tests may be running unattended -- don't wait forever! pm.setTimeoutMsec(timeout); pm.setEcho(false); pm.setEnvironment(envp); int exit; String myErr = ""; try { exit = pm.execute(); } catch (ProcessManagerTimeoutException tex) { myErr = "\nProcessManagerTimeoutException: command timed out after " + timeout + " ms."; exit = 1; } catch (ProcessManagerException ex) { ex.printStackTrace(); myErr = "\n" + ex.getMessage(); exit = 1; } NadminReturn ret = new NadminReturn(exit, pm.getStdout(), pm.getStderr() + myErr, args[0]); write(ret.outAndErr); return ret; }
logger.fine("Error while executing command: " + ex.getMessage());
private void waitForever() throws InterruptedException, ProcessManagerException { if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } process.waitFor(); }
public static void main(String[] args) { try { if (args.length <= 0) { System.out.println("Usage: ProcessManager cmd arg1 arg2 ... argn"); System.exit(1); } List<String> cmds = new ArrayList<String>(); cmds.addAll(Arrays.asList(args)); ProcessManager pm = new ProcessManager(cmds); pm.execute(); System.out.println("*********** STDOUT ***********\n" + pm.getStdout()); System.out.println("*********** STDERR ***********\n" + pm.getStderr()); System.out.println("*********** EXIT VALUE: " + pm.getExitValue()); } catch (ProcessManagerException pme) { pme.printStackTrace(); } } ////////////////////////////////////////////////////////////////////////////
logger.fine("Error while executing command: " + ex.getMessage());
private void writeStdin() throws ProcessManagerException { if (stdinLines == null || stdinLines.length <= 0) { return; } PrintWriter pipe = null; try { pipe = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream()))); for (int i = 0; i < stdinLines.length; i++) { debug("InputLine ->" + stdinLines[i] + "<-"); pipe.println(stdinLines[i]); } pipe.flush(); } catch (Exception e) { throw new ProcessManagerException(e); } finally { try { pipe.close(); } catch (Throwable t) { } } }
public static void main(String[] args) { try { if (args.length <= 0) { System.out.println("Usage: ProcessManager cmd arg1 arg2 ... argn"); System.exit(1); } List<String> cmds = new ArrayList<String>(); cmds.addAll(Arrays.asList(args)); ProcessManager pm = new ProcessManager(cmds); pm.execute(); System.out.println("*********** STDOUT ***********\n" + pm.getStdout()); System.out.println("*********** STDERR ***********\n" + pm.getStderr()); System.out.println("*********** EXIT VALUE: " + pm.getExitValue()); } catch (ProcessManagerException pme) { pme.printStackTrace(); } } ////////////////////////////////////////////////////////////////////////////
logger.fine("Error while executing command: " + ex.getMessage());
private void writeStdin() throws ProcessManagerException { if (stdinLines == null || stdinLines.length <= 0) { return; } PrintWriter pipe = null; if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } try { pipe = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream()))); for (int i = 0; i < stdinLines.length; i++) { debug("InputLine ->" + stdinLines[i] + "<-"); pipe.println(stdinLines[i]); } pipe.flush(); } catch (Exception e) { throw new ProcessManagerException(e); } finally { try { pipe.close(); } catch (Throwable t) { } } }
logger.fine("Error while executing command: " + ex.getMessage());
private void writeStdin() throws ProcessManagerException { if (stdinLines == null || stdinLines.length <= 0) { return; } PrintWriter pipe = null; if(process == null) { throw new ProcessManagerException(Strings.get("null.process")); } try { pipe = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream()))); for (int i = 0; i < stdinLines.length; i++) { debug("InputLine ->" + stdinLines[i] + "<-"); pipe.println(stdinLines[i]); } pipe.flush(); } catch (Exception e) { throw new ProcessManagerException(e); } finally { try { pipe.close(); } catch (Throwable t) { } } }
} catch (ProcessManagerException ex) { msg2 = Strings.get("node.command.failed.local.details", ex.getMessage(), nr.getLastCommandRun()); logger.warning(StringUtils.cat(": ", msg1, msg2, msg3)); ex.getMessage()); } catch (UnsupportedOperationException e) { msg2 = Strings.get("node.not.ssh", nodeName, nodeHost);
public int execute() throws ProcessManagerException { if (!asadmin.canExecute()) throw new ProcessManagerException("asadmin is not executable!"); pm = new ProcessManager(cmds); pm.waitForReaderThreads(waitForReaderThreads); pm.execute(); // blocks until command is complete return pm.getExitValue(); }
return ex.getMessage();
public int execute() throws ProcessManagerException { if (!asadmin.canExecute()) throw new ProcessManagerException("asadmin is not executable!"); pm = new ProcessManager(cmds); pm.waitForReaderThreads(waitForReaderThreads); pm.execute(); // blocks until command is complete return pm.getExitValue(); }
ex.getMessage(), nr.getLastCommandRun()); logger.warning(StringUtils.cat(": ", msg1, msg2, msg3)); ex.getMessage());
public int execute() throws ProcessManagerException { if (!asadmin.canExecute()) throw new ProcessManagerException("asadmin is not executable!"); pm = new ProcessManager(cmds); pm.waitForReaderThreads(waitForReaderThreads); pm.execute(); // blocks until command is complete return pm.getExitValue(); }