Run the given command and output the result
@param command
@param options
335480
function runCommand(command, options) {
    let cmd = getCommand(command);
    if (!cmd || command === 'help') {
      cmd = getCommand('help');
    } else {
      try {
        validateConfig(options);
      } catch (error) {
        console.log(error.message);
        process.exit(1);
      }
    }
    let fn = cmd.callback;
    let opts = mapParams(cmd, options);
    fn(opts).then(function (result) {
      if (cmd.formatter) {
        cmd.formatter.format(result.messages, options);
      } else {
        console.log(result);
      }
    }).catch(function (error) {
      let formatter = new formatters.MessageFormatter();
      if (error.response) {
        console.log(error);
        formatter.format(['Error response received: ' + error.response.data.errors[0].message]);
      } else {

        formatter.format([error.message]);
      }
      process.exit(1);
    });
  }
1069704
public void process(Map<String, String> options) {
        Log.info("Initializing Commands...");
        for (Map.Entry<String, String> entry : options.entrySet()) {
            AbstractCommand command = PreConfigurationContext.getCommandByName(entry.getKey());
            if (null != command) {
                command.setCommands(options);
                try {
                    command.init();
                } catch (InitializationException e) {
                    Log.error("There is a problem in the option you configured: ", entry.getKey(),
                            ErrorGuide.getGuide(ErrorGuide.OPTION_ERROR));
                }
                command.execute();
                command.stop();
            }
            Log.info(entry.getKey() + " Command Initialized.");
        }
    }
177139
function run(options, ast, cb) {
  var report = new Report(options, ast);
  report.run(cb);
}
1232179
private function executeCommand(Command $command, $path, array $options)
    {
        $oldCwd = getcwd();

        $this->logger->info('Execute command '.$command->getCommand().' from '.$path);

        if (!chdir($path)) {
            $this->logger->error('Cannot change directory to '.$path);

            return new CommandResult($command->getCommand(), array(), 1, $options);
        }

        exec($command->getCommand(), $out, $resultCode);
        $out = is_array($out) ? $out : array();

        $this->logger->info('Exit code =  '.$resultCode);
        if ($resultCode !== 0) {
            $this->logger->error('Cannot execute command '.$command->getCommand().' from '.$path);
        }

        chdir($oldCwd);

        return new CommandResult($command->getCommand(), $out, $resultCode, $options);
    }
1054000
def run_command(command, options={})
      timeout = options[:timeout] || 7200

      # default to adding a nice 13 if nothing specified
      nice = if options.key?(:nice)
        (options[:nice] == 'n') ? '' : "nice -n #{options[:nice]} "
      else
        'nice -n 19 '
      end

      echo_return = (options.key?(:echo_return) && !options[:echo_return]) ? '' : '; echo $?'

      cmd = "#{nice}#{command}#{echo_return}"

      logger.info "run_command: #{cmd}"
      begin
        result = Timeout::timeout(timeout) {
          Open3::popen3(cmd) do |i,o,e|
            out_str = ""
            err_str = ""
            i.close # important!
            o.sync = true
            e.sync = true
            o.each{|line|
              out_str << line
              line.chomp!
              logger.debug "stdout:    #{line}"
            }
            e.each { |line|
              err_str << line
              line.chomp!
              logger.debug "stderr:    #{line}"
            }
            return out_str, err_str
          end
        }
      rescue Timeout::Error => toe
        logger.error "run_command:Timeout Error - running command, took longer than #{timeout} seconds to execute: '#{cmd}'"
        raise toe
      end
    end
1208433
protected function executeShellCommand($command, array $options = [])
    {
        $return = 0;
        passthru('DEV_QUIET=true '.$this->replaceVars($command, $this->getConfig()), $return);

        if (0 !== $return) {
            throw new \RuntimeException(
                (isset($options['v']) && true === $options['v'])
                    ? sprintf("Execution failed for [%s]", $command)
                    : "Execution failed",
                ($return > 0 && 256 > $return) ? $return : 255
            );
        }

        return $this;
    }
551861
public static boolean runCommand(final Process p, final OutputStream output) {
        return runCommand(p, output, output, new ArrayList<String>());
    }
319881
public static void runShellCommand(String cmd,
                                     StringBuilder outputLines,
                                     StringBuilder errorLines)
    throws IOException {
    runShellCommand(new String[] {cmd}, outputLines, errorLines);
  }
47063
function run(command, auth, options, async, done, msgSuccess, msgSuccessAsync, msgFailure) {

        var args,
            flags,
            field,
            i,
            childProcess;

        // Pass auth.
        command = command.replace('{auth}', auth ? format('--email=%s --passin ', auth.email) : '');

        // Evaluate arguments to pass.
        args = '';
        for (field in options.args) {
            args += format('--%s=%s ', field, options.args[field]);
        }

        // Evaluate flags to pass.
        flags = '';
        for (i = 0; i < options.flags.length; ++i) {
            flags += format('--%s ', options.flags[i]);
        }

        command = command.replace('{args}', args).replace('{flags}', flags).replace('{path}', options.path);

        // Passin.
        if (auth) {
            command = format('echo %s | %s', auth.password, command);
        }

        // Run it asynchronously
        if (async) {
            command = COMMAND_ASYNC.
                replace('{command}', command).
                replace('{redirect}', options.asyncOutput ? '' : REDIRECT_DEVNULL);
        }

        grunt.log.debug(command);

        // Run the command.
        childProcess = exec(command, {}, function () {});

        // Listen to output
        if (options.stdout) {
            childProcess.stdout.on('data', function (d) {
                grunt.log.write(d);
            });
        }

        // Listen to errors.
        if (options.stderr) {
            childProcess.stderr.on('data', function (d) {
                grunt.log.error(d);
            });
        }

        // Listen to exit.
        childProcess.on('exit', function (code) {
            if (options.stdout) {
                if (code === 0 && async) {
                    grunt.log.subhead(
                        msgSuccessAsync ||
                        options.asyncOutput && 'Output from asynchronous operation follows.' ||
                        'Unable to determine success of asynchronous operation. For debugging please disable async mode or enable asyncOutput.'
                    );
                } else if (code === 0) {
                    grunt.log.ok(msgSuccess || 'Action executed successfully.');
                }
            }

            if (options.stderr && code !== 0) {
                grunt.log.error(msgFailure || 'Error executing the action.');
            }

            done();
        });

    }
312242
function safeExec(command, options) {
  const result = exec(command, options);
  if (result.code !== 0) {
    exit(result.code);
    return null;
  }
  return result;
}
608968
function exec(command, options) {
    return ((args) => spawn(args.shift(), args, options))(command.split(' '));
}
152866
public void run(String[] args) {
    // Add and parse options.
    OptionParser parser = new OptionParser();
    initializeCommonOptions(parser);
    initializeOptions(parser);

    String errorMessage = null;
    try {
      parsedOptions = parser.parse(args);
    } catch (OptionException e) {
      errorMessage = e.getMessage();
    }

    boolean printHelp = false;
    if (errorMessage != null) {
      // If an error occurs, the options don't parse.
      // Therefore, we must manually check if the help option was
      // given.
      for (int i = 0; i < args.length; i++) {
        if (args[i].equals("--help")) {
          printHelp = true;
        }
      }
    }

    if (errorMessage != null && !printHelp) {
      System.err.println(errorMessage);
      System.err.println("Try --help for more information about options.");
      System.exit(1);
    }

    if (printHelp || parsedOptions.has(helpOpt)) {
      // If a help option is given, print help then quit.
      try {
        parser.printHelpOn(System.err);
      } catch (IOException ioException) {
        throw new RuntimeException(ioException);
      }
      System.exit(0);
    }

    // Log any passed-in options.
    if (!parsedOptions.has(noPrintOptions)) {
      System.out.println("Command-line options:");
      for (OptionSpec<?> optionSpec : parsedOptions.specs()) {
        if (parsedOptions.hasArgument(optionSpec)) {
          System.out.println("--" + Iterables.getFirst(optionSpec.options(), "") + " "
              + Joiner.on(" ").join(parsedOptions.valuesOf(optionSpec)));
        } else {
          System.out.println("--" + Iterables.getFirst(optionSpec.options(), ""));
        }
      }
      System.out.println("");
    }

    // Run the program.
    long startTime = System.currentTimeMillis();
    processOptions(parsedOptions);
    run(parsedOptions);
    long endTime = System.currentTimeMillis();

    if (!parsedOptions.has(noPrintOptions)) {
      System.out.println("Total time elapsed: " + TimeUtils.durationToString(endTime - startTime));
    }

    System.exit(0);
  }
268815
public static void executeCommand(String[] args) throws IOException {

            OptionParser parser = getParser();

            // declare parameters
            String url = null;

            // parse command-line input
            OptionSet options = parser.parse(args);
            if(options.has(AdminParserUtils.OPT_HELP)) {
                printHelp(System.out);
                return;
            }

            // check required options and/or conflicting options
            AdminParserUtils.checkRequired(options, AdminParserUtils.OPT_URL);

            // load parameters
            url = (String) options.valueOf(AdminParserUtils.OPT_URL);

            // execute command
            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            doMetaCheckVersion(adminClient);
        }
1320753
public function execute($command, $option = [])
    {
        $commandClass = "\\Friday\\Console\\Command\\".ucfirst($command)."Command";
        $cmd = new $commandClass($option);
        $this->output = $cmd->run();
    }
1371015
public function commandRun(ScheduledCommandInterface $command, $runCommand)
    {
        if ($this->optionReader->isDebugMode()) {
            $this->output->writeln('     <info>'.$command->getName().'</info>: '.$runCommand);
        }
    }
887887
function run (command, opts, conf) {
  // Use "new Promise" to isolate process and catch any error
  return new Promise(function (resolve, reject) {
    if (command.config) {
      opts = command.config(opts, conf);
    }

    Promise.cast(command.run(opts.argv, opts, conf)).then(resolve, reject);
  });
}
819599
public function execute(array $args = [], array $options = [])
    {
        if (!$this->evaluate($this->condition)) {
            return;
        }

        $this->command->execute($args, $options);
    }