wood burning stoves*
The moose likes Java in General and the fly likes Communicating with unix command process from java using stream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Communicating with unix command process from java using stream" Watch "Communicating with unix command process from java using stream" New topic
Author

Communicating with unix command process from java using stream

megha joshi
Ranch Hand

Joined: Feb 20, 2007
Posts: 206
Hi all,

I want to use stream based IPC in Java. To test this I am trying to exec unix more filename command from my java code. Interesting thing is commands like ps, man, ls -l execute fine using the code below. But executing more on a big file , which requires enter input from keyboard occasionally fails. I would like to give input to this unix process from my java code..but I am not sure how to do that. The code I have so far is as follows:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

Search for the Javaworld article "When Runtime.exec() won't". It's a must-read when working with Processes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
megha joshi
Ranch Hand

Joined: Feb 20, 2007
Posts: 206
Thanks..I went through it though issues mentioned in the article, are not relevant for this case. Any other suggestions? Thanks again!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

megha joshi wrote:issues mentioned in the article, are not relevant for this case.

Are you sure? Perhaps the process is being paused because its output / error buffer is full, something that is very clearly discussed in the article. Once you clear the output and error buffers it may continue again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Communicating with unix command process from java using stream
 
Similar Threads
reading byte array
how to do?
How to send comands to anoyther program
java program run external command on Unix
IPC through streams