private ExecBean auxRun(String program, List<String> args, Map<String, String> env)
    throws NotAuthorizedException, ExecuteException, IOException {
    DefaultExecutor executor = new DefaultExecutor();
    executor.setExitValues(null);

    // Setup stdout and stderr
    int nbytes = appConf.getInt(AppConfig.EXEC_MAX_BYTES_NAME, -1);
    ByteArrayOutputStream outStream = new MaxByteArrayOutputStream(nbytes);
    ByteArrayOutputStream errStream = new MaxByteArrayOutputStream(nbytes);
    executor.setStreamHandler(new PumpStreamHandler(outStream, errStream));

    // Only run for N milliseconds
    int timeout = appConf.getInt(AppConfig.EXEC_TIMEOUT_NAME, 0);
    ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
    executor.setWatchdog(watchdog);

    CommandLine cmd = makeCommandLine(program, args);

    LOG.info("Running: " + cmd);
    ExecBean res = new ExecBean();

    res.exitcode = executor.execute(cmd, execEnv(env));

    String enc = appConf.get(AppConfig.EXEC_ENCODING_NAME);
    res.stdout = outStream.toString(enc);
    res.stderr = errStream.toString(enc);
    try {
      watchdog.checkException();
    }
    catch (Exception ex) {
      LOG.error("Command: " + cmd + " failed. res=" + res, ex);
    }
    if(watchdog.killedProcess()) {
      String msg = " was terminated due to timeout(" + timeout + "ms).  See " + AppConfig
              .EXEC_TIMEOUT_NAME + " property"; 
      LOG.warn("Command: " + cmd + msg + " res=" + res);
      res.stderr += " Command " + msg; 
    }
    if(res.exitcode != 0) {
      LOG.info("Command: " + cmd + " failed. res=" + res);
    }
    return res;
  }
Run the program synchronously as the given user.  Warning:
CommandLine will trim the argument strings.

@param program   The program to run.
@param args      Arguments to pass to the program
@param env       Any extra environment variables to set
@return The result of the run.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/ExecServiceImpl.java