public int execute(final String user, final List<String> command) throws IOException {
    log.info("Command: " + command);
    final Process process = new ProcessBuilder()
        .command(constructExecuteAsCommand(user, command))
        .inheritIO()
        .start();

    int exitCode;
    try {
      exitCode = process.waitFor();
    } catch (final InterruptedException e) {
      log.error(e.getMessage(), e);
      exitCode = 1;
    }
    return exitCode;
  }
public int execute ( final String user , final List < String > command ) throws IOException { log . info ( "Command: " + command ) ; final Process process = new ProcessBuilder ( ) . command ( constructExecuteAsCommand ( user , command ) ) . inheritIO ( ) . start ( ) ; int exitCode ; try { exitCode = process . waitFor ( ) ; } catch ( final InterruptedException e ) { log . error ( e . getMessage ( ) , e ) ; exitCode = 1 ; } return exitCode ; }
API to execute a command on behalf of another user.

@param user The proxy user
@param command the list containing the program and its arguments
@return The return value of the shell command