Note that there are some explanatory texts on larger screens.

plurals
  1. POCommunicating with a command line tool in Java
    text
    copied!<p>I want to use a linux command line tool from my Java program. I start the program and get the output using the Process class (<a href="http://download.oracle.com/javase/6/docs/api/java/lang/Process.html" rel="nofollow noreferrer">http://download.oracle.com/javase/6/docs/api/java/lang/Process.html</a>):</p> <pre><code> /* @param args * @throws IOException */ public static void main(String[] args) throws IOException { Process proc = Runtime.getRuntime().exec("octave"); BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedReader errorReader = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())); int c; while((c = proc.getInputStream().read()) != -1) { System.out.print((char)c); } System.out.println("End"); } </code></pre> <p>I get the following output:</p> <blockquote> <p>GNU Octave, version 3.0.5 Copyright (C) 2008 John W. Eaton and others. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.</p> <p>Octave was configured for "i486-pc-linux-gnu".</p> <p>Additional information about Octave is available at <a href="http://www.octave.org" rel="nofollow noreferrer">http://www.octave.org</a>.</p> <p>Please contribute if you find this software useful. For more information, visit <a href="http://www.octave.org/help-wanted.html" rel="nofollow noreferrer">http://www.octave.org/help-wanted.html</a></p> <p>Report bugs to (but first, please read <a href="http://www.octave.org/bugs.html" rel="nofollow noreferrer">http://www.octave.org/bugs.html</a> to learn how to write a helpful report).</p> <p>For information about changes from previous versions, type `news'.</p> </blockquote> <p>The strange thing is the normal output if I run octave in the Terminal is the following:</p> <blockquote> <p>:~/workspace/Console/src/c$ octave<br> GNU Octave, version 3.0.5 Copyright (C) 2008 John W. Eaton and others. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.</p> <p>Octave was configured for "i486-pc-linux-gnu".</p> <p>Additional information about Octave is available at <a href="http://www.octave.org" rel="nofollow noreferrer">http://www.octave.org</a>.</p> <p>Please contribute if you find this software useful. For more information, visit <a href="http://www.octave.org/help-wanted.html" rel="nofollow noreferrer">http://www.octave.org/help-wanted.html</a></p> <p>Report bugs to (but first, please read <a href="http://www.octave.org/bugs.html" rel="nofollow noreferrer">http://www.octave.org/bugs.html</a> to learn how to write a helpful report).</p> <p>For information about changes from previous versions, type `news'.</p> <p>octave:1> </p> </blockquote> <p>So the characters in the line where the input is requested are not sent in my input stream. Why? Isn't it possible to detect whether input is requested? </p> <p>Thanks for your answers!</p> <p>Heinrich</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload