I want to run multiple cmd commands succesively from java code one after the other.
I want to use this one command line application which creates ssh connection and I want to run multiple commands succesively like in a normal command prompt window without actually closing the session. Most answers I found about running cmd command from java talked about running a single command and then stopping. Like the answer in this question:
I need to redirect the output of my commands to the console and also get the new commands as inputs from the console. Sort of like emulating a cmd window using java code. And then end the cmd session as necessary and continue with the rest of the program.
EDIT:
I am trying to run a command line implementation of Putty
called plink
. It is used as
plink -ssh <hostname> -P <port> -l <username> -pw <password>
in cmd and then the linux terminal of the host is emulated on the cmd. After that you run all the usual linux commands like ls
straight into the command prompt. So I want to emulate that without closing the supposedly emulated command prompt of my java code.