Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Process and his OutputStream

 
Stefan Litzel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

i hope you can help me with my little problem.

I want to execute a cmd command with the ProcessBuilder, but for some reason writing information to the stdin of the console doesnt work properly.

I tried the following:



The output on the console is as expected the question for the admin password. But when i try to write the pass to the console nothing happens.


Best wishes

Stefan Litzel
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Litzel wrote:But when i try to write the pass to the console nothing happens.


Is your code even getting that far? You are reading from the process' output stream until EOF (indicated by a null). I wouldn't expect that to happen until the process terminates. Try printing to the screen between your read and write.
 
Stefan Litzel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also tried it without the InputStream of the cmd program. Still the same.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic