Re: how to pass input to processes' stdin using OSProcessHandler?

Hello Jhonny,

You need to flush the stream returned by getProcessInput() after you write
data to it.

Hello, I need to pass a password to an application invoked using
OSProcessHandler.

The code is as follows:

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("/opt/appengine-go/appcfg.py -e
myemail@gmail.com --passin update APP_DIR");
OSProcessHandler handler = new OSProcessHandler(proc,null);
String password = "mypassword";
byte[] theByteArray = password.getBytes();
handler.getProcessInput().write(theByteArray);
consoleView.attachToProcess(handler);
handler.startNotify();
When I run the same command from terminal, I get prompted for password
and I am able to type it, and it uploads. How can I reproduce that?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
1 comment

Hello Jhonny,

You need to flush the stream returned by getProcessInput() after you write
data to it.

Hello, I need to pass a password to an application invoked using
OSProcessHandler.

The code is as follows:

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("/opt/appengine-go/appcfg.py -e
myemail@gmail.com --passin update APP_DIR");
OSProcessHandler handler = new OSProcessHandler(proc,null);
String password = "mypassword";
byte[] theByteArray = password.getBytes();
handler.getProcessInput().write(theByteArray);
consoleView.attachToProcess(handler);
handler.startNotify();
When I run the same command from terminal, I get prompted for password
and I am able to type it, and it uploads. How can I reproduce that?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.