Hi,

How can i make sure if channel is closed after complete execution.

And make use of getExitStatus method to ensure if script execution was
successful.

Please find the below snippet

```

ExecChannel channel = ssh.execChannel(serviceScript);

bufferedReader = new BufferedReader(new
InputStreamReader(channel.getOutput()));
String msg=null;
LOGGER.info(String.format("Initiated sending logs to subscribed user %s",
prinicipal.getName()));
RealTimeExecutionLogs realTimeExecutionLogs = new RealTimeExecutionLogs();;
while((msg=bufferedReader.readLine())!=null){
LOGGER.info(msg);
realTimeExecutionLogs.setContent(msg);
template.convertAndSendToUser(prinicipal.getName(),
"/queue/executeService", realTimeExecutionLogs);
}

channel.getExitStatus().get() -------- the exit status of the command if it
was received, or {@code null} if this information
    *         was not received.

```


Thanks & regards,
Poornima.BS

Reply via email to