aspose file tools*
The moose likes Beginning Java and the fly likes Executing system command and obtaining result in real-time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Executing system command and obtaining result in real-time" Watch "Executing system command and obtaining result in real-time" New topic
Author

Executing system command and obtaining result in real-time

Andy McBee
Greenhorn

Joined: Jul 23, 2009
Posts: 5
It's easy to launch some program and then - when this program finishes - get a result (stdout, for instance). I use the following code:

But how can i get stream contents in real time?
Being precise, i have a program that prints a line every n seconds; and i want to launch it from java code and every n seconds process the line it prints.
Andy McBee
Greenhorn

Joined: Jul 23, 2009
Posts: 5
Ok, i found that problem is somewhere else - this code doesn't print output typically produced by Process.exe - it just exits.

UPD. It does exactly what i need, just a few lines need to be replaced:
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36501
    
  16
Andy McBee wrote:It's easy to launch some program . . .
Easy? It is usually complicated, and whenever we see people using Runtime.exec() we tell them to search for when Runtime.exec() won't.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing system command and obtaining result in real-time
 
Similar Threads
getting input from the command line
How to get a value from process
Problems while executing unix script from Java...
Compilation of java code at runtime
I need help refining some code