Executing system command and obtaining result in real-time
Andy McBee
Greenhorn
Joined: Jul 23, 2009
Posts: 5
posted
0
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
posted
0
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: 32712
4
posted
0
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Executing system command and obtaining result in real-time