Run registered console command. Artisan commands will running too.

@param string $command
@return string Printed data from command
553875
public function pulse(string $command, bool $force = false)
    {
        return $this->run('php pulse ' . $command . ($force ? ' --force' : ''));
    }
1262293
public function execute($command)
    {
        $validator = $this->translator->toValidator($command);

        if (class_exists($validator)) {
            $this->app->make($validator)->validate($command);
        }

        return $this->bus->execute($command);
    }
401615
private function run($command, $input)
    {
        $process = proc_open($command, [
            ['pipe', 'r'], // stdin
            ['pipe', 'w'], // stdout
            ['pipe', 'w'], // stderr
        ], $pipes);

        fwrite($pipes[0], $input);
        fclose($pipes[0]);

        $result = stream_get_contents($pipes[1]);
        fclose($pipes[1]);

        $errors = stream_get_contents($pipes[2]);
        fclose($pipes[2]);

        $code = proc_close($process);

        if (0 != $code) {
            $errors = trim($errors) ?: 'unknown';
            throw SignException::signFailedAsOf($errors, $code);
        }

        return $result;
    }
651690
public function runCommand($command)
    {
        $this->setAutoExit(false);
        $argv = explode(' ','application '.$command);
        $input = new ArgvInput($argv);
        $this->run($input);
    }
1113628
public function execute($command = null, array $args = array(), array $options = array())
    {
        $command = $command ?: $this->defaultCommand;
        if (!isset($this->commands[$command])) {
            throw new ConsoleException("Command '$command' does not exist");
        }
        
        $callback = $this->commands[$command];
        if (is_callable($callback)) {
            $params = array($args, $options);
            if (is_string($callback)) {
                if (strpos($callback, '::') !== false) {
                    list($classname, $methodname) = explode('::', $callback);
                    $reflection = new ReflectionMethod($classname, $methodname);
                } else {
                    $reflection = new ReflectionFunction($callback);
                }
                $params = Utils::computeFuncParams($reflection, $args, $options);
            }
            $params[] = $this;
            return call_user_func_array($callback, $params);
        }

        $method = new ReflectionMethod($callback, 'execute');
        $params = Utils::computeFuncParams($method, $args, $options);
        return $method->invokeArgs(new $callback($this), $params);
    }
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);
    }
1170245
public function run_command($command) {
        \Log::debug($command);

        $descriptorspec = array(
            1 => array('pipe', 'w'),
            2 => array('pipe', 'w'),
        );
        $pipes = array();
        /* Depending on the value of variables_order, $_ENV may be empty.
         * In that case, we have to explicitly set the new variables with
         * putenv, and call proc_open with env=null to inherit the reset
         * of the system.
         *
         * This is kind of crappy because we cannot easily restore just those
         * variables afterwards.
         *
         * If $_ENV is not empty, then we can just copy it and be done with it.
         */
        if(count($_ENV) === 0) {
            $env = NULL;
            foreach($this->envopts as $k => $v) {
                putenv(sprintf("%s=%s",$k,$v));
            }
        } else {
            $env = array_merge($_ENV, $this->envopts);
        }
        $cwd = $this->repo_path;
        $resource = proc_open($command, $descriptorspec, $pipes, $cwd, $env);

        $stdout = stream_get_contents($pipes[1]);
        $stderr = stream_get_contents($pipes[2]);
        foreach ($pipes as $pipe) {
            fclose($pipe);
        }

        $status = trim(proc_close($resource));
        if ($status) throw new Exception($stderr);

        return $stdout;
    }
301137
public function runCommand(Command $command, array $parameters = [], OutputInterface $output = null)
    {
        $parameters['command'] = $command->getName();
        $input = new ArrayInput($parameters);

        if ($output === null) {
            $output = new NullOutput();
        }

        $command->setApplication(new SymfonyConsoleApplication());

        return $command->run($input, $output);
    }
1333324
private function runRemote($command) {
		// make commands a list
		if (!is_array($command))
			$command = array($command);
		$command = strval(implode(';', $command));
		
		return $this->runLocal(['plink',
					'-ssh',					// interacting method
					'-i', static::safeDir($this->ppk),		// Private key file to access server
					$this->host,			// username and hostname to connect to
			
					'"' . $command . '"',	// Commands to run
		]);
	}
289368
protected function runCommand(Command $command, array $argv, ConsoleIo $io)
    {
        try {
            return $command->run($argv, $io);
        } catch (StopException $e) {
            return $e->getCode();
        }
    }
1264270
public function exec($command)
    {
        if ( ! ($stream = ssh2_exec($this->connection, $command))) {

            throw new Ssh2CommandException("Exec failed: '{$command}'.");
        }

        stream_set_blocking($stream, true);

        $data = '';

        while ($buf = fread($stream, 4096)) {

            $data .= $buf;
        }

        fclose($stream);

        return $data;
    }
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;
    }
449686
protected function execute($command)
    {
        $process = proc_open($command, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
        fclose($pipes[2]);
        $this->output = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        $status = proc_get_status($process);
        $this->status = $status['exitcode'];
        proc_close($process);
    }
684671
public function processCommand($command)
    {
        // Add environment flag to commands
        $stage = $this->connections->getCurrentConnectionKey()->stage;
        if (Str::contains($command, 'artisan') && $stage) {
            $command .= ' --env="'.$stage.'"';
        }

        return $command;
    }
497658
protected function run($command)
    {
        if (array_key_exists('migrationPath', $this->config)) {
            $migrationPaths = $this->config['migrationPath'];

            if (is_string($migrationPaths)) {
                $migrationPaths = [$migrationPaths];
            }

            $this->runMigrationByPaths($migrationPaths, $command);
        } elseif (array_key_exists('migrationNamespaces', $this->config)) {
            $migrationNamespaces = $this->config['migrationNamespaces'];

            if (is_string($migrationNamespaces)) {
                $migrationNamespaces = [$migrationNamespaces];
            }

            $this->runMigrationByNamespaces($migrationNamespaces, $command);
        } else {
            $this->runMigrationByApplication($command);
        }
    }
987635
private function _run($command) 
	{
		if ($this->options['type'] === self::TYPE_PHP) {
			// Old Option: Run direct from terminal (doesn't like brackets too much).
			// $cmd = "php -r \"{$command}\"";

			// New Option: Save to temp file & run it.
			$this->savedFiles[] = $this->options['tmp-dir'] . 'async-tmp-' . time() . '.php';
			$result = file_put_contents(
				end($this->savedFiles),
				$this->_generateCode($command),
				LOCK_EX
			);

			if ($result !== false) {
				$cmd = "php " . end($this->savedFiles);
			}
			else {
				$cmd = "php --help";
			}
		}
		else {
			$cmd = $command;
		}

		if ($this->options['async']) {
			// This forks the process.
			// Helpful guide @ https://segment.com/blog/how-to-make-async-requests-in-php/
			$cmd .= ' > /dev/null 2>&1 &';
		}

		exec($cmd, $output, $exit);

		if ($this->options['debug']) {
			echo '<br />Command Run: ' . $cmd;
		}

		return $exit === 0;
	}
231964
protected function run($command, $standardInput = null)
    {
        $stdOut = '';
        $stdErr = '';
        $stdOut = array();
        $rc = $this->processExecutor->execute($command, $stdOut);
        $stdOut = (string) $stdOut;
        $stdErr = (string) $this->processExecutor->getErrorOutput();

        return array($rc, $stdOut, $stdErr);
    }