Run the command and return its results

@param   string  $command
@return  null|string
@throws  \Exception
321447
public function exec($command)
    {
        // run command
        $exit = -1;
        $logfile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tika-error.log';
        $descriptors = [['pipe', 'r'], ['pipe', 'w'], ['file', $logfile, 'a']];
        $process = proc_open($command, $descriptors, $pipes);
        $callback = $this->callback;

        // get output if command runs ok
        if(is_resource($process))
        {
            fclose($pipes[0]);
            $this->response = '';
            while($chunk = stream_get_line($pipes[1], $this->chunkSize))
            {
                if(!is_null($callback))
                {
                    $callback($chunk);
                }

                $this->response .= $chunk;
            }
            fclose($pipes[1]);
            $exit = proc_close($process);
        }

        // exception if exit value is not zero
        if($exit > 0)
        {
            throw new Exception("Unexpected exit value ($exit) for command $command");
        }

        return trim($this->response);
    }
258226
protected function executeCmd($command)
    {
        $process = new $this->processClass($command);
        $process->run();

        if (false === $process->isSuccessful() && strlen($process->getErrorOutput()) > 0) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return $process->getOutput();
    }
472986
public function run($command = null) {
		if (!$command) {
			$this->_renderCommands();
			return true;
		}

		if (!preg_match('/\\\\/', $command)) {
			$command = Inflector::camelize($command);
		}

		if (!$class = Libraries::locate('command', $command)) {
			$this->error("Command `{$command}` not found");
			return false;
		}

		if (strpos($command, '\\') !== false) {
			$command = join('', array_slice(explode("\\", $command), -1));
		}
		$command = strtolower(Inflector::slug($command));

		$run = null;
		$methods = $this->_methods($class);
		$properties = $this->_properties($class);
		$info = Inspector::info($class);

		$this->out('USAGE', 'heading');

		if (isset($methods['run'])) {
			$run = $methods['run'];
			unset($methods['run']);
			$this->_renderUsage($command, $run, $properties);
		}
		foreach ($methods as $method) {
			$this->_renderUsage($command, $method);
		}
		$this->out();

		if (!empty($info['description'])) {
			$this->nl();
			$this->_renderDescription($info);
			$this->nl();
		}

		if ($properties || $methods) {
			$this->out('OPTIONS', 'heading');
		}
		if ($run) {
			$this->_render($run['args']);
		}
		if ($methods) {
			$this->_render($methods);
		}
		if ($properties) {
			$this->_render($properties);
		}
		$this->out();
		return true;
	}
1167916
public function get($command) {
        return isset($this->_commands[$command]) ?
            $this->_commands[$command] :
            null;
    }
1075591
public function execute(Command $command)
    {
        $handler = $this->resolver->resolve($command);

        return $handler->handle($command);
    }
1197968
public function run($command)
    {
        $this->command = escapeshellcmd($command);
        $this->process->setCommandLine($this->command);
        $this->process->run();
        $this->validateRun();

        return $this;
    }
714524
public function runCommand($command, $parameters = array(), OutputInterface $output = null)
    {
        $parameters = array_merge(
            array('command' => $command),
            $this->getDefaultParameters(),
            $parameters
        );

        $this->getApplication()->setAutoExit(false);
        $exitCode = $this->getApplication()->run(new ArrayInput($parameters), $output ?: new NullOutput());

        if (1 === $exitCode) {
            throw new \RuntimeException('This command terminated with a permission error');
        }

        if (0 !== $exitCode) {
            $this->getApplication()->setAutoExit(true);

            $errorMessage = sprintf('The command terminated with an error code: %u.', $exitCode);
            $this->output->writeln("<error>$errorMessage</error>");
            $exception = new \Exception($errorMessage, $exitCode);

            throw $exception;
        }

        return $this;
    }
94018
protected function executeCommand($command)
    {
        $result = @exec($command, $output, $code);
        $output = implode("\n", $output);

        if ($result === false) {
            throw new Exception("Failed to execute command '$command' with message: [$code] '$output'");
        }

        return $output;
    }
1289995
public function execute($command, callable $next)
    {

        if ($command instanceof BackgroundCommand && !$command->isRunningInBackground()) {
            return $this->runProcess($command);
        }

        return $next($command);
    }
1356319
public function exec($command)
    {
        // Check for prohibited commands
        foreach ($this->prohibitedCommands as $prohibitedCommand) {
            if (strpos(trim($command), $prohibitedCommand) !== false) {
                throw new \Exception('The shell command ' . $command . ' is prohibited');
            }
        }
        return exec($command);
    }
463404
private function run (string $command) : ?string
    {
        $result = \trim(\shell_exec($command) ?? "");

        return "" !== $result
            ? $result
            : null;
    }
611624
public function run(string $command) : Process {
        $mutedCommand = Str::startsWith($command, 'artisan')
            ? str_replace('artisan ', '', $command)
            : $command;

        ignore_user_abort();

        $logName    = explode(' -', $mutedCommand, 2)[0];
        $log        = storage_path('logs' . DIRECTORY_SEPARATOR . snake_case(Str::slug($logName)) . '.log');
        $rootPath   = base_path();

        shell_exec("cd $rootPath && php artisan $mutedCommand >> " . $log . " &");

        exec('pgrep php', $processIds);
        exec('ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs', $processes);

        $this->check();

        return $this->getProcessByCommand($command);
    }
1242469
protected function composerRunCommand($command)
    {
        $this->info("Run \"$command\".");

        $output = [];
        exec($command, $output, $returnStatusCode);

        if ($returnStatusCode !== 0) {
            throw RuntimeException::commandExecutionFailed($command, $returnStatusCode);
        }

        $this->info("\"$command\" was successfully ran.");
    }
375116
public function run(string $command = '')
    {
        // load input definition configure
        $this->configure();

        if ($this->input->sameOpt(['h', 'help'])) {
            $this->showHelp();
            return 0;
        }

        // some prepare check
        if (true !== $this->prepare()) {
            return -1;
        }

        // return False to deny go on
        if (false === $this->beforeExecute()) {
            return -1;
        }

        // if enable swoole coroutine
        if (static::isCoroutine() && Helper::isSupportCoroutine()) {
            $result = $this->coroutineRun();
        } else { // when not enable coroutine
            $result = $this->execute($this->input, $this->output);
        }

        $this->afterExecute();

        return $result;
    }
952652
public function execute($command, callable $next)
    {
        $filename = $command->getFile()->path();
        $this->apiDocBuilder->debug('Starting to parse file: ' . $filename);
        try {
            return $next($command);
        } catch (\Exception $e) {
            $this->apiDocBuilder->log('Unable to parse file "' . $filename . '", ' . $e->getMessage());
        }
        return null;
    }
1314291
public function execute($command)
    {
        $deferred = new Deferred();

        if ($this->ending) {
            $deferred->reject(new RuntimeException('Shell is ending already'));
        } else {
            $this->pending []= $deferred;

            $this->sendCommand($command);
        }

        return $deferred->promise();
    }
1275535
public function execute($command, callable $next)
    {
        try {
            return $next($command);
        } catch (ExceptionInterface $exception) {
            throw $exception;
        } catch (ValidationException $exception) {
            $this->exceptionHandler->throwServiceExceptionFromViolationException($exception);
        } catch (RequestException $exception) {
            $this->exceptionHandler->throwServiceExceptionFromRequestException($exception);
        } catch (\Throwable $exception) {
            $this->exceptionHandler->throwServiceException($exception);
        }
    }