0

I know, my English is not good. Sorry for this. So I try to explain with an example.

I have to do it for 5-6 examples and I will show you one of them. If anyone know how to do logic and answer me, it will be nice.

String cmd = "openssl enc -aes-256-cbc -e -in " + path + " -out " + path+"_E";
Process pb = Runtime.getRuntime().exec(cmd);
pb.waitFor();

If I enter this code in Terminal manually, it will ask me encryption password and I will be enter. After that, it ask me re-enter encryption password and I will be enter.

What I want is that, can I handle both enter and re-enter things from java code ? I want to enter automatically from java.

PS: I do not want to disable to use password! I want enter from java code.

Thanks for answers.

Prodian
  • 71
  • 9

1 Answers1

0

You can handle it all through java. See this post User input to the command line when using Runtime.getRuntime().exec(command);

As is mentioned in that post you can redirect the output stream of the process and send commands from Java using:

out = p.getOutputStream();
out.write("fooUsername\n".getBytes());
out.flush();