I need to execute a script package from Java that executes
1) After starting it performs a long (up to several seconds) task.
2) Then the prompt "Password:" will be displayed.
3) Then the user enters the password and presses the Enter key.
4) Then the script exits.
I know how to run a script from Java, I know how to read the output of a script package in Java, but I do not know how to wait for the password hint to appear (how can I get to what the script package is waiting for the password to be entered).
So my question is: how do I know when a script package printed an invitation?
At the moment, I have the following code:
final Runtime runtime = Runtime.getRuntime();
final String command = ... ;
final Process proc = runtime.exec(command, null, this.parentDirectory);
final BufferedReader input = new BufferedReader(new InputStreamReader(
proc.getInputStream()));
String line = null;
while ((line = input.readLine()) != null) {
LOGGER.debug("proc: " + line);
}
source
share