Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Open Text Summarizer on Ubuntu, and it works fine from my terminal... To use it I have to run the following command in terminal:

    ots -r 5 /home/arslan/tempEclipse.txt

Now I want to use this in Java so what I did is I used the following code:

    Process p1 = r.exec("echo Hello World > /home/arslan/tempEclipse.txt");
    Process p = r.exec("ots -r 5 /home/arslan/tempEclipse.txt");
    BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while ((line = b.readLine()) != null) {

Now the first part of this code has to do with executing a terminal command which redirects input to a file... This is not happening... I even changed that files permission to 777 but still nothing gets written into it... The second command gets run if I already write the file with some text in it... (Process p)... but the first terminal command doesn't...

There is a workaround (I think) the ots command needs input via file or stdin now if I let go of the file system and go with stdin then I may be able to get what I want... but what is stdin then and how can I incorporate it in java?

share|improve this question
Well, I did the file writing part in Java and then ots part using the runtime terminal code... But still finding the answer to this phenomenon would be a great help –  ArslanW May 19 '13 at 21:57
What is the type of your 'r' object in the sample code? It may be the case that shell output redirection syntax is not supported by that class's exec method. –  Paul May 19 '13 at 22:51
r is of type Runtime and I also think you're right... most things run fine but input redirection apparently isn't... –  ArslanW May 23 '13 at 17:37
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.