sshj icon indicating copy to clipboard operation
sshj copied to clipboard

While execution a command - not clear what's going on

Open arturmkr opened this issue 4 years ago • 0 comments

I want to connect by ssh to remote host and execute a script, execution of script could take some time.

I am using following command:

String response = "";
String command = "./script.sh";
        try (Session session = sshClient.startSession()) {
            final Session.Command cmd = session.exec(command);
            response = (IOUtils.readFully(cmd.getInputStream()).toString());
        }
logger.info(response);

So, I would be able to get a response only, when a command is fully executed. As a result, while execution a script, I don't know, what's going on.

Questions:

  1. Is it possible to print in STDOUT - what is going while executing a script ?
  2. Is it possible to print in STDOUT - errors while executing a script? Because after executing wrong command, for example "jjjj" I am not able to see any errors like "command not found: jjj" ?

arturmkr avatar Apr 24 '20 19:04 arturmkr