From: Jack on 1 Apr 2010 01:54 On Mar 31, 6:11 am, Paul Cager <paul.ca...(a)googlemail.com> wrote: > On Mar 31, 7:53 am, Jack <junw2...(a)gmail.com> wrote: > ... > > > Runtime.getRuntime().exec("myscript"); > > > How to pass in the password automatically if I store the password in a > > String? Here there is no use/program interaction. There is no user to > > type in the password. > > > Thanks. > > > Jack > > If you can't alter the script (or don't want to send the password as > an argument, e.g. for security concerns), then you could write input > to the process's stdin: > > Process p = Runtime.getRuntime().exec("...."); > p.getOutputStream().write("MyPassword".getBytes()); > p.getOutputStream().close(); > > (That should work for Linux, but I'm not too familiar with Windows). > > However a script to read a password might not read from standard input > (it might open the terminal directly so that it can control character > echoing). In that case things get complicated... The script is a windows batch file. I want to call it in my java code. Thanks.
From: Johannes Schneider on 2 Apr 2010 06:16 Jean-Baptiste Nizet wrote: > The easiest way is certainly to modify the script. It might take a > unique argument which would be the password, so you could start it > with > > myscript mySecretPassword Don't do this. If you do this, "ps aux" will show the password. Johannes
First
|
Prev
|
Pages: 1 2 Prev: duplicate java on windows Next: How to specify the main() class in "jar -cfe ..." ? |