I know how to invoke command line in Java like this
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("dir && c: && dir"); // also can run multiple command with &&
then I can print its response while getting its InputStream
this is working fine I found very good examples here. I can also run multiple commands one after another while putting &&
in between commands. But once I invoked rt.exec()
after that i cannot run any other command meaning i lose control from command line meaning only i can print InputStream
.
My problem is that I want to run command and after analyzing its response i want to write next command dynamically according to previous command response.
Note: I can run multiple commands with &&
but its only when i know what will happen after one command and while assuming I run next command like we run in Real Command Line Window
?