• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime exec() multiple parameters  RSS feed

 
martin backman
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if the header conforms to the actual question, but English is not my native tongue, if not; I'm sorry.

problem:
I execute a command, but when executed the terminal gives me a question to input my password, how do I do this?



???

Thanks
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write to the process using the Process' getOutputStream method.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you should probably use getInputStream() to read the question text from the process, as well as read any other output from the process. (Output from the process is input for you.)

You should probably read the classic article When Runtime.exec() won't, as it discusses many common problems with exec(). Note that it was written before JDK 1.5 came out, which included the ProcessBuilder class. ProcessBuilder is basically an improved version of exec(), which solves some problems and gives you more control over some aspects of the process. I recommend you use it instead of exec(). But the JavaWorld article will still be useful to you, as many of the old issues remain.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!