In the main body, I start a cycle (50 iterations), in the body of which the output of the text on the screen and the injection of commands into the stream. When compiling, it first displays 50 lines of text on the screen, and then it only starts working with streams. Example:

 PrintWriter stdin = new PrintWriter(cmd_proc.getOutputStream()); for (int i = 0; i<50; i++) { System.out.println(i); stdin.println(comand_execute); //посылаем команды в консоль stdin.flush(); } 

At the output I get: "1,2,3, ... 50", and then (seconds after 3) the commands sent to the stream are executed sequentially.

How to achieve the "correct" (sequential) operations? (1-team, 2-team, 3-team, .... 50-team)

1 answer 1

It is better to do so.

  Runtime.getRuntime().exec("host -ta " + domain); p.waitFor(); 

Then the output of commands can be intercepted.