private void doExec(final Shell.ShellCommandExecutor shell,
    final ShellExecResponse.Builder builder) throws IOException {
    try {
      shell.execute();
      builder.setExitCode(shell.getExitCode()).setStdout(shell.getOutput());
    } catch (Shell.ExitCodeException e) {
      LOG.warn("Launched process failed", e);
      builder.setExitCode(e.getExitCode()).setStdout(shell.getOutput()).setStderr(e.getMessage());
    }
  }
Execute {@code shell} and collect results into {@code builder} as side-effects.
hbase-it/src/test/java/org/apache/hadoop/hbase/ShellExecEndpointCoprocessor.java