• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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