Hi forum,
Please help me. I've been searching for hours for what is wrong and I can safely say im lost
Here is my code:
and...protected Collection<String> executeCommand(String cmd) { //Result of the command output Collection<String> resultString = new ArrayList<String>(); try { // Execute command Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(cmd); logger.debug("cmd: " + cmd); // Class to do outputting... StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? int exitVal = proc.waitFor(); logger.debug("Exit status: " + exitVal); } catch (Throwable t) { t.printStackTrace(); } return resultString; }
class StreamGobbler extends Thread { InputStream is; String type; StreamGobbler(InputStream is, String type) { this.is = is; this.type = type; } public void run() { try { logger.debug("in run"); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line=null; while ( (line = br.readLine()) != null) logger.debug(type + ">" + line); } catch (IOException ioe) { ioe.printStackTrace(); } } }
This is the error i get:
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Unknown Source)
at java.lang.UNIXProcess.waitFor(Unknown Source)
at gsoa.rim.CommunicationsCheck.executeCommand(Commun icationsCheck.java:177)
which points to the .waitFor() function call...
Why would it get interrupted if we are asking it to wait until its done?
Pleaasee help!


LinkBack URL
About LinkBacks
Reply With Quote
by clicking the
button on their useful posts.