/**
   * Perform given command.
   *
   * @param cmd : command to execute
   * @param waitTime : time in milliseconds to wait for command to complete.
   */
  private void doListener(String[] cmd, int waitTime) {
    ProcessExecutor pe = new ProcessExecutor();
    pe.setCommands(cmd);
    pe.setTimeout(2000);
    pe.run();

    if (waitTime != 0) {
      try {
        Thread.sleep(waitTime);
      } catch (InterruptedException e) {
      }
    }
  }
 /**
  * Execute an OS command and return the result of stdout.
  *
  * @param command Command to run
  * @return Returns output of the command in a string
  * @throws ReplicatorException Thrown if command execution fails
  */
 public String exec(String command) throws ReplicatorException {
   String[] osArray = {"sh", "-c", command};
   ProcessExecutor pe = new ProcessExecutor();
   pe.setCommands(osArray);
   if (logger.isDebugEnabled()) {
     logger.debug("Executing OS command: " + command);
   }
   pe.run();
   if (logger.isDebugEnabled()) {
     logger.debug("OS command stdout: " + pe.getStdout());
     logger.debug("OS command stderr: " + pe.getStderr());
     logger.debug("OS command exit value: " + pe.getExitValue());
   }
   if (!pe.isSuccessful()) {
     logger.error(
         "OS command failed: command="
             + command
             + " rc="
             + pe.getExitValue()
             + " stdout="
             + pe.getStdout()
             + " stderr="
             + pe.getStderr());
     throw new ReplicatorException("OS command failed: command=" + command);
   }
   return pe.getStdout();
 }