aspose file tools*
The moose likes Java in General and the fly likes Runtime.getRuntime() execute script which asks for input from user. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Runtime.getRuntime() execute script which asks for input from user." Watch "Runtime.getRuntime() execute script which asks for input from user." New topic
Author

Runtime.getRuntime() execute script which asks for input from user.

sandeep dhingra
Ranch Hand

Joined: Jul 30, 2005
Posts: 41
I have to run script on Unix which after execution asks for input from the user, this is done 4-5 times. After every input the user presses the enter key.

How do I implement this using Runtime get Runtime() in my Java application?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42932
    
  68
First of all, you should get familiar with how Runtime.exec deals with the input and output of the processes it starts. This article is a very good start.

Then you'll need to think about reading and parsing the input stream. How do you find out when the script is done sending (probably at a line end), and what do you need to send as response?

Does the Java code know how to respond to the script, or must it show the script output to the user, and ask for input from him?
[ February 06, 2008: Message edited by: Ulf Dittmer ]
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282


Whatever the user keystrokes shows up in the variable input.


"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime.getRuntime() execute script which asks for input from user.