Search in sources :

Example 1 with DefaultExecuteResultHandler

use of com.jn.langx.commandline.DefaultExecuteResultHandler in project agileway by fangjinuo.

the class SshCommandLineExecutorTest method showResult.

private static void showResult(SshCommandLineExecutor executor) {
    DefaultExecuteResultHandler resultHandler = (DefaultExecuteResultHandler) executor.getResultHandler();
    if (resultHandler.hasResult()) {
        Throwable exception = resultHandler.getException();
        if (exception != null) {
            logger.error(exception.getMessage(), exception);
        } else {
            OutputAsStringExecuteStreamHandler output = (OutputAsStringExecuteStreamHandler) executor.getStreamHandler();
            String str = output.getOutputContent();
            logger.info(str);
        }
    }
}
Also used : OutputAsStringExecuteStreamHandler(com.jn.langx.commandline.streamhandler.OutputAsStringExecuteStreamHandler) DefaultExecuteResultHandler(com.jn.langx.commandline.DefaultExecuteResultHandler)

Aggregations

DefaultExecuteResultHandler (com.jn.langx.commandline.DefaultExecuteResultHandler)1 OutputAsStringExecuteStreamHandler (com.jn.langx.commandline.streamhandler.OutputAsStringExecuteStreamHandler)1