Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sandeep dhingra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Whatever the user keystrokes shows up in the variable input.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic