Source:
<code>public ICommandResult executeCommand(final String command, final IProgressMonitor monitor) throws ExecutionException { if (fConnection.isOpen()) { FutureTask<CommandResult> future = new FutureTask<>(new Callable<CommandResult>() { @Override public CommandResult call() throws IOException, CancellationException { synchronized (fConnection) { IRemoteProcessBuilder processBuilder = fConnection.getProcessBuilder(splitCommand(command)); IRemoteProcess process= processBuilder.start(); InputReader stdout= new InputReader(process.getInputStream()); InputReader stderr= new InputReader(process.getErrorStream()); try { stdout.waitFor(); stderr.waitFor(); <START> int result = process.waitFor(); <END> String output= stdout.getOutput(); String error= null; if (result != 0) { error= stderr.getOutput(); if (error.length() == 0) { error= output; } } return new CommandResult(result, splitLines(output), splitLines(error)); } catch (InterruptedException e) { return new CommandResult(1, new String[0], new String[] {e.getMessage()}); } finally { stdout.stop(); stderr.stop(); } } } private String[] splitLines(String output) { if (output == null) { return null; } return output.split("\\r?\\n"); } private String[] splitCommand(String shellCommand) { return shellCommand.trim().split("\\s+"); } }); fExecutor.execute(future); try { return future.get(ControlPreferences.getInstance().getCommandTimeout(), TimeUnit.SECONDS); } catch (java.util.concurrent.ExecutionException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionFailure, ex); } catch (InterruptedException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionCancelled, ex); } catch (TimeoutException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionTimeout, ex); } } throw new ExecutionException(Messages.TraceControl_ShellNotConnected, null); }</code><technical_language>this works fine for build-in SSH. However, RSE backend problems change. For example, process.waitFor() returns 0 if command fails. Another problem is stdout.getOutput() contains other sub-strings acutal command output (e.g. Login ...) 2 problems (result 0 additional output) reason in original code sandwich command echo command (markup). Also, able get result command line output (follow member fReturnValue). this current version of change RSE backend</technical_language>

Target:
public ICommandResult executeCommand(final String command, final IProgressMonitor monitor) throws ExecutionException { if (fConnection.isOpen()) { FutureTask<CommandResult> future = new FutureTask<>(new Callable<CommandResult>() { @Override public CommandResult call() throws IOException, CancellationException { if (monitor == null || !monitor.isCanceled()) { final boolean isRSE = RSE_ADAPTER_ID.equals(fConnection.getRemoteServices().getId()); IRemoteProcess process = startRemoteProcess(isRSE, command); InputReader stdout = new InputReader(process.getInputStream()); InputReader stderr = new InputReader(process.getErrorStream()); try { stdout.waitFor(monitor); stderr.waitFor(monitor); if (monitor == null || !monitor.isCanceled()) { return createResult(isRSE, process.waitFor(), stdout.toString(), stderr.toString()); } } catch (OperationCanceledException e) { } catch (InterruptedException e) { return new CommandResult(1, new String[0], new String[] {e.getMessage()}); } finally { stdout.stop(); stderr.stop(); process.destroy(); } } return new CommandResult(1, new String[0], new String[] {"cancelled"}); } }); fExecutor.execute(future); try { return future.get(ControlPreferences.getInstance().getCommandTimeout(), TimeUnit.SECONDS); } catch (java.util.concurrent.ExecutionException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionFailure, ex); } catch (InterruptedException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionCancelled, ex); } catch (TimeoutException ex) { throw new ExecutionException(Messages.TraceControl_ExecutionTimeout, ex); } finally { future.cancel(true); } } throw new ExecutionException(Messages.TraceControl_ShellNotConnected, null); }