1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.util.io.StreamFlusher; 27 import com.sun.enterprise.util.OS; 28 import java.io.File ; 29 30 36 public class CLIProcessExecutor 37 { 38 Process process; 39 40 public CLIProcessExecutor() { 41 process = null; 42 } 43 44 45 51 public void execute(String [] cmd, boolean wait) throws Exception 52 { 53 process=Runtime.getRuntime().exec(cmd); 54 56 StreamFlusher sfErr=new StreamFlusher(process.getErrorStream(), System.err, null); 58 sfErr.start(); 59 60 StreamFlusher sfOut=new StreamFlusher(process.getInputStream(), System.out); 62 sfOut.start(); 63 try { 64 Thread.currentThread().sleep(5000); 68 if (wait) { 72 process.waitFor(); 73 } 74 } 75 catch (InterruptedException ie) { 76 } 77 } 78 79 84 public int exitValue() { 85 if (process == null) return -1; 86 return process.exitValue(); 87 } 88 89 } 90 | Popular Tags |