HI,

The getExitStatus().get() call should block until the command
completes. When it's done, it is just a matter of calling
"channel.close()" and that will close all open streams and release the
resources associated to this connection.


I.

On 20 January 2017 at 14:32, Poornima BS <poornimabs.g...@gmail.com> wrote:
> 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