runs given command and returns a handle to it

@param   string  $command
@param   string  $redirect  optional  how to redirect error output
@return  resource
@throws  \RuntimeException
775723
private function runCommand(string $command, string $redirect = '2>&1')
    {
        $pd = popen($command . ' ' . $redirect, 'r');
        if (false === $pd) {
            throw new \RuntimeException('Can not execute ' . $command);
        }

        return $pd;
    }
917981
public function handle(SingleCommand $command)
    {
        /** @var MigrationRunner $runner */
        $runner = $this->getRunner();
        $runner = $runner->withContext($command->getContext());
        $event = $runner->run(
            $command->getTarget(),
            $command->getOptions()
        );
        return $command->getVersionRepository()->update($event->getTarget());
    }
420967
function runCommand($command, callable $onError = null)
    {
        $onError = $onError ?: function () {};

        // Symfony's 4.x Process component has deprecated passing a command string
        // to the constructor, but older versions (which Valet's Composer
        // constraints allow) don't have the fromShellCommandLine method.
        // For more information, see: https://github.com/laravel/valet/pull/761
        if (method_exists(Process::class, 'fromShellCommandline')) {
            $process = Process::fromShellCommandline($command);
        } else {
            $process = new Process($command);
        }

        $processOutput = '';
        $process->setTimeout(null)->run(function ($type, $line) use (&$processOutput) {
            $processOutput .= $line;
        });

        if ($process->getExitCode() > 0) {
            $onError($process->getExitCode(), $processOutput);
        }

        return $processOutput;
    }
235637
public function call($command, array $parameters = [], $outputBuffer = null)
    {
        if ($this->ajax() === true) {
            $this->lastOutput = $outputBuffer ?: new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true, new OutputFormatter(true));
            $this->setCatchExceptions(true);
        } else {
            $this->lastOutput = $outputBuffer ?: new BufferedOutput();
            $this->setCatchExceptions(false);
        }

        $command = $command.' '.implode(' ', $parameters);
        $input = new StringInput($command);
        $input->setInteractive(false);

        $result = $this->run($input, $this->lastOutput);

        $this->setCatchExceptions(true);

        return $result;
    }
303840
public function run(CommandInterface $command, $result = null)
    {
        $key = $command->getRequestMethod() === 'GET' ? 'query' : 'body';
        $options = [$key => []];

        if(!empty($params = $command->getParams())) {
            $options[$key] = array_merge($options[$key], $params);
        }

        if($config = $this->getConfig()) {
            if(!empty($config->getSteamKey())) {
                $options[$key]['key'] = $config->getSteamKey();
            }

            $this->urlBuilder->setBaseUrl($config->getBaseSteamApiUrl());
        }

        $request = new Request(
            $command->getRequestMethod(),
            $this->urlBuilder->build($command)
        );

        return $this->client->sendAsync($request, $options);
    }
440343
public function get($command, $arguments = array())
    {
        $options = $this->getOptions();
        $consoleDir = $this->getConsoleDir();

        if (null === $consoleDir) {
            return;
        }

        $argumentString = '';

        foreach ($arguments as $argument) {
            $argumentString .= escapeshellarg($argument) . ' ';
        }

        $process = $this->executeCommand($consoleDir, $command . ' ' . $argumentString, false);

        echo $process->getOutput();
    }
140954
protected function forceRedirect($redirectTo = '')
    {
        if (empty($redirectTo))
        {
            $this->runDefaultBehavior();
        }

        Craft::$app->response->redirect($redirectTo, $this->settings->redirectStatusCode);
    }
618732
public function execute(interfaces\commands\Command $command)
    {
        $handler = $this->resolver->resolve($command);
        
        return call_user_func([$handler, 'handle'], $command);
    }
641305
protected function onErrorResponse(string $command, array $args, RedisException $error)
    {
        $details = \explode(' ', $error->getMessage(), 2);
        switch ($details[0]) {
            case 'MOVED':
                return $this->onMovedResponse($command, $args, $details[1]);
            case 'ASK':
                return $this->onAskResponse($command, $args, $details[1]);
            default:
                throw $error;
        }
    }
197078
public function run(CommandInterface $command, $result = null)
    {
        if(!$result instanceof ResponseInterface) {
            throw new \InvalidArgumentException(
                'The result needs to be an instance of GuzzleHttp\Message\ResponseInterface');
        }

        return json_decode($result->getBody()->getContents(), true);
    }
49604
private function execute(Command $command)
    {
        $exec = $this->exec;
        $exec->setCommand($command);
        $code = $exec->run();
        $output = $exec->getOutput();

        if ($exec->hasErrors()) {

            switch ($code) {
                case 127:
                    $msg = 'git command not found, make sure it is installed an in the system path';
                    break;
                default:
                    $msg = 'Git execution failed : ' .$code . ' ' . $output['stderror'];
                    break;
            }

            throw new \RuntimeException($msg, $code);
        }

        return $code;
    }
1367294
public static function run($name, $args = [], $redirectStdinStdout = null, $pipeType = null)
    {
        $cmd = Imi::getImiCmd('process', 'start') . ' -name ' . $name;
        if(null !== $redirectStdinStdout)
        {
            $cmd .= ' -redirectStdinStdout ' . $redirectStdinStdout;
        }
        if(null !== $pipeType)
        {
            $cmd .= ' -pipeType ' . $pipeType;
        }
        return \Swoole\Coroutine::exec($cmd);
    }
32726
public function call($command, array $parameters = array())
	{
		$parameters['command'] = $command;

		$this->lastOutput = new BufferedOutput;

		return $this->find($command)->run(new ArrayInput($parameters), $this->lastOutput);
	}
1236718
protected function handle(CommandInterface $command)
	{
		if($command instanceof SelfHandlingCommandInterface)
		{
			return $command->handle();
		}

		$handler = $this->resolveCommandHandler($command);

		return $this->executeCommandHandler($handler, $command);
	}
877154
public function execUpdate($redirectAction = false)
    {
        // database translations
        $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE));
        //validate and extract input
        $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
        if($input) {
            //extract primary key value
            $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a');
            try{
                //ORM insert
                $this->purgePrimaryKeyValue($input);
                if($this->update($primaryKeyValue, $input)) {
                    $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['update-success'], $this->translations[$this->name]['singular']));
                }
            } catch(\PDOException $exception) {
                $this->messages->save('cookies', 'danger', $this->handleError($exception));
                if(!isset($redirectAction)) {
                    $redirectAction = 'update-form/' . $this->extractPrimaryKeyValue($input, 's');
                }
            }
        }
        //redirect
        $redirectAction = $redirectAction ? $redirectAction : 'list';
        $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction);
    }
260875
private static function runCommand($command)
    {
        if (!function_exists('proc_open')) {
            return null;
        }

        $descriptorSpec = [
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $process = proc_open($command, $descriptorSpec, $pipes, null, null, ['suppress_errors' => true]);
        if (!is_resource($process)) {
            return null;
        }

        $info = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        fclose($pipes[2]);
        proc_close($process);

        return $info;
    }
1029438
final protected function redirectToRoute($route)
    {
        $url = $this->urlBuilder->build($route);

        if ($url !== null) {
            $this->response->redirect($url);
        } else {
            throw new RuntimeException(sprintf('Unknown route supplied for redirection "%s"', $route));
        }
    }