sshj
sshj copied to clipboard
While execution a command - not clear what's going on
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:
- Is it possible to print in STDOUT - what is going while executing a script ?
- 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" ?