how to input password to a process waiting for password

I have created a java program in which i am using system.exec to run a dos command.

this dos command requires password input by the user after entering in command prompt.

as i am calling it through System.exec() can i enter the password with my java code.

If anyone has any idea please suggest.

thanks,

[333 byte] By [comperAbhia] at [2007-10-2 12:55:42]
# 1

hello,

Runtime.getRuntime().exec(String command);

return a new process object for managing the subprocess. after this

you can gets the output stream of the subprocess and then pass him the password.

Process p = null;

PrintWriter pw = null;

try

{

p = Runtime.getRuntime().exec(String command);

pw = new PrintWriter(p.getOutputStream(), true /*autoflush*/);

pw.printf(password);

}

catch(Exception e)

{

e.printStackTrace();

}

by gino

Gino86a at 2007-7-13 10:11:10 > top of Java-index,Core,Core APIs...