Execute the command

@return bool whether execution was successful. If false, error details can be obtained through
getError(), getStdErr() and getExitCode().
497254
public function execute()
    {
        $command = $this->getExecCommand();

        if (!$command) {
            return false;
        }

        if ($this->useExec) {
            $execCommand = $this->captureStdErr ? "$command 2>&1" : $command;
            exec($execCommand, $output, $this->_exitCode);
            $this->_stdOut = implode("\n", $output);
            if ($this->_exitCode!==0) {
                $this->_stdErr = $this->_stdOut;
                $this->_error = empty($this->_stdErr) ? 'Command failed' : $this->_stdErr;
                return false;
            }
        } else {
            $descriptors = array(
                1   => array('pipe','w'),
                2   => array('pipe', $this->getIsWindows() ? 'a' : 'w'),
            );
            if ($this->_stdIn!==null) {
                $descriptors[0] = array('pipe', 'r');
            }

            $process = proc_open($command, $descriptors, $pipes, $this->procCwd, $this->procEnv, $this->procOptions);

            if (is_resource($process)) {

                if ($this->_stdIn!==null) {
                    if (is_resource($this->_stdIn) &&
                        in_array(get_resource_type($this->_stdIn), array('file', 'stream'), true)) {
                        stream_copy_to_stream($this->_stdIn, $pipes[0]);
                    } else {
                        fwrite($pipes[0], $this->_stdIn);
                    }
                    fclose($pipes[0]);
                }
                $this->_stdOut = stream_get_contents($pipes[1]);
                $this->_stdErr = stream_get_contents($pipes[2]);
                fclose($pipes[1]);
                fclose($pipes[2]);

                $this->_exitCode = proc_close($process);

                if ($this->_exitCode!==0) {
                    $this->_error = $this->_stdErr ? $this->_stdErr : "Failed without error message: $command";
                    return false;
                }
            } else {
                $this->_error = "Could not run command $command";
                return false;
            }
        }

        $this->_executed = true;

        return true;
    }
740008
public function execute()
	{
		putenv('LINES=' . $this->terminal->getHeight());
		putenv('COLUMNS=' . $this->terminal->getWidth());

		$this->configureIO();

		try
		{
			$this->dispatchEvent(ApplicationEvents::BEFORE_EXECUTE);

			// Perform application routines.
			$exitCode = $this->doExecute();

			$this->dispatchEvent(ApplicationEvents::AFTER_EXECUTE);
		}
		catch (\Throwable $throwable)
		{
			if (!$this->shouldCatchThrowables())
			{
				throw $throwable;
			}

			$event = new ApplicationErrorEvent($throwable, $this, $this->runningCommand);

			$this->dispatchEvent(ConsoleEvents::APPLICATION_ERROR, $event);

			$exitCode = $event->getExitCode();

			if (is_numeric($exitCode))
			{
				$exitCode = (int) $exitCode;

				if ($exitCode === 0)
				{
					$exitCode = 1;
				}
			}
			else
			{
				$exitCode = 1;
			}
		}
		finally
		{
			if ($this->shouldAutoExit() && isset($exitCode))
			{
				$exitCode = $exitCode > 255 ? 255 : $exitCode;
				$this->close($exitCode);
			}
		}
	}
613356
public function run()
    {
        $error = $this->error;
        $output = $this->output;

        return $this->builder->getProcess()->run(
            function ($type, $buffer) use ($error, $output) {
                if ('err' === $type) {
                    if ($error) {
                        $error($buffer);
                    }
                } elseif ($output) {
                    $output($buffer);
                }
            }
        );
    }
968838
public function execute() {
        $endpoint = "batch";
        $path = $this->build_path($endpoint);

        $ch = curl_init($path);

        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, self::HTTP_POST);

        // set payload
        $payload_string = json_encode($this->commands);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $payload_string);

        // set headers
        $httpheaders = array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($payload_string),
            $this->API_HEADER_KEY . ": " . $this->API_KEY,
            $this->API_HEADER_CLIENT . ": " . $this->API_CLIENT_STUB
        );

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/data/ca-certificates.pem');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheaders);

        if ($this->DEBUG) {
            // enable curl verbose output to STDERR
            curl_setopt($ch, CURLOPT_VERBOSE, true);

            $this->log_message(sprintf("payload: %s\r\npath: %s\r\n", $payload_string, $path));
        }

        $code = null;

        try {
            $result = curl_exec($ch);
            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            $response = json_decode( $result );

            if ($code != 200) {
                throw new API_Error("Request was not successful", $code, $result, $response);
            }
        } catch (API_Error $e) {
            if ($this->DEBUG) {
                $this->log_message(
                    sprintf("Caught exception: %s\r\n%s", $e->getMessage(), print_r($e, true)),
                    self::LOG_ERR
                );
            }

            $response = (object) array(
                'code' => $code,
                'status' => "error",
                'success' => false,
                'exception' => $e
            );
        }

        curl_close($ch);
        $this->commands = array();

        return $response;
    }
41855
public function execute()
    {
        set_error_handler([$this, 'processErrors'], E_WARNING);

        $stream = fopen($this->requestData['url'], 'r', false, $this->streamContext);

        $this->responseBody = stream_get_contents($stream);

        $this->responseHeaders = $http_response_header;

        $this->response = implode("\r\n", $http_response_header) . "\r\n\r\n" . $this->responseBody;

        restore_error_handler();
    }
863228
public function fire()
    {
        parent::fire();

        if ($this->option('install-ruleset')) {
            if ($this->installRuleset()) {
                $this->info('Copied ruleset to '.$this->pathRulesetLocal);
            }
        }

        $this->info('Runing PHP Mess Detector...');

        $command = $this->pathCli.' ';
        $command.= base_path().'/'.$this->option('path').' ';
        $command.= 'text ';
        $command.= $this->pathRuleset;

        passthru($command, $exitCode);

        $this->info('Done.');

        return $exitCode;
    }
317600
public function handle()
    {
        $env = new Env(base_path('.env'));
        $key = strtoupper($this->argument('key'));
        $value = (string) $this->argument('value');
        $linebreak = (bool) $this->option('line-break');

        $result = $env->set($key, $value, $linebreak)->get($key);

        if ($result !== $value) {
            $env->rollback();

            return $this->error('Could not set the value in your .env file, reverting...');
        }

        return $this->comment("Successfully set [$key] to [$value] in your .env file.");
    }
1308430
public function handle()
    {
        $name = $this->qualifyClass($this->getNameInput());

        $path = $this->getPath($name);

        // First we will check to see if the class already exists. If it does, we don't want
        // to create the class and overwrite the user's code. So, we will bail out so the
        // code is untouched. Otherwise, we will continue generating this class' files.
        if ($this->alreadyExists($this->getNameInput())) {
            $this->error($this->type.' already exists!');

            return false;
        }

        // Next, we will generate the path to the location where this class' file should get
        // written. Then, we will build the class and make the proper replacements on the
        // stub files so that it gets the correctly formatted namespace and class name.
        $this->makeDirectory($path);

        $this->files->put($path, $this->buildClass($name));

        $this->info($this->type.' created successfully.');
    }
675387
public function execute()
    {
        $this->phpci->quiet = true;
        $this->phpci->logExecOutput(false);

        foreach ($this->directories as $dir) {
            $this->lintDirectory($dir);
        }

        $this->phpci->quiet = false;
        $this->phpci->logExecOutput(true);

        $errors = 0;
        $warnings = 0;

        foreach ($this->failedPaths as $path) {
            if ($path['type'] == 'error') {
                $errors++;
            } else {
                $warnings++;
            }
        }

        $this->build->storeMeta('phptallint-warnings', $warnings);
        $this->build->storeMeta('phptallint-errors', $errors);
        $this->build->storeMeta('phptallint-data', $this->failedPaths);

        $success = true;

        if ($this->allowed_warnings != -1 && $warnings > $this->allowed_warnings) {
            $success = false;
        }

        if ($this->allowed_errors != -1 && $errors > $this->allowed_errors) {
            $success = false;
        }

        return $success;
    }
449285
public function execute() {
        global $CFG;

        if (!empty($CFG->skiplangupgrade)) {
            mtrace('Langpack update skipped. ($CFG->skiplangupgrade set)');

            return;
        }

        $controller = new \tool_langimport\controller();
        if ($controller->update_all_installed_languages()) {
            foreach ($controller->info as $message) {
                mtrace($message);
            }
            return true;
        } else {
            foreach ($controller->errors as $message) {
                mtrace($message);
            }
            return false;
        }

    }
486692
public function execute()
    {
        $command = new \ReflectionClass($this);
        $options = input()->get();

        if (empty($options)) {
            $this->optionHelp();
        } else {

            foreach ($options as $method => $arguments) {

                if (array_key_exists('-' . $method, $this->commandOptionsShortcuts)) {
                    $method = $this->commandOptionsShortcuts[ '-' . $method ];
                }

                $optionMethod = camelcase('option-' . $method);

                if ($command->hasMethod($optionMethod)) {

                    $commandMethod = $command->getMethod($optionMethod);

                    if ($commandMethod->getNumberOfRequiredParameters() == 0) {
                        call_user_func([&$this, $optionMethod]);
                    } elseif ($commandMethod->getNumberOfRequiredParameters() > 0 and empty($arguments)) {
                        if (isset($this->commandOptions[ $method ][ 'help' ])) {
                            output()->write(
                                (new Format())
                                    ->setContextualClass(Format::INFO)
                                    ->setString(language()->getLine('CLI_USAGE') . ':')
                                    ->setNewLinesBefore(1)
                                    ->setNewLinesAfter(1)
                            );

                            output()->write(
                                (new Format())
                                    ->setContextualClass(Format::INFO)
                                    ->setString(language()->getLine($this->commandOptions[ $method ][ 'help' ]))
                                    ->setNewLinesAfter(2)
                            );
                        }
                    } else {
                        $optionArguments = is_array($arguments)
                            ? $arguments
                            : [$arguments];

                        call_user_func_array([&$this, $optionMethod], $optionArguments);
                    }
                }
            }
        }
    }
788946
public function handle()
    {
        $command = $this->option('command');

        ob_start();
        $result = $this->executeCode(
            trim(trim($command), ';').';'
        );
        $output = ob_get_clean();

        if (empty($output) === false) {
            $this->line($output);
            $result = null;
        }

        $this->getOutput()->write('=> ');
        switch (gettype($result)) {
            case 'object':
            case 'array':
                $this->line(var_export($result, true));
                break;
            case 'string':
                $this->comment($result);
                break;
            case 'NULL':
                $this->line('');
                break;
            default:
                is_numeric($result) === true ? $this->info($result) : $this->line($result);
                break;
        }
    }
737945
public function handle()
    {

        // Ask what command
        $command = $this->choice('What command are you running?', $this->availableCommands->toArray());

        if (!$this->availableCommands->has($command)) {
            $this->info('The specified command does not exist.');
            return;
        }

        $method = 'make' . ucfirst($command);
        call_user_func([$this, $method]);

        $this->call('make:'. $command, $this->options);
    }
297495
public function execute()
    {
        // Get the parameters
        $params = $this->getParams();

        // Get the url
        $url = $this->getUrl($params);

        // Run it
        return $this->sendRequest($url, $params);
    }
774116
public function execute() {
        $this->log
            ->printAsMessage()
            ->info($this->getDescription())
            ->printEmptyLine()
            ->printAsOutput();

        ksort($this->config['commands']);

        $maxCommandLength = 0;

        foreach (array_keys($this->config['commands']) as $command) {
            if (is_string($command) && strlen($command) > $maxCommandLength) {
                $maxCommandLength = strlen($command);
            }
        }

        $tab = 4;
        $minLength = $tab * (int) ($maxCommandLength / $tab) + $tab;

        foreach ($this->config['commands'] as $command => $details) {
            $this->log->info(
                str_pad($command, $minLength) . '<dim>' . $details['description'] . '</dim>'
            );
        }

        return $this;
    }
158802
public function executeCommand()
    {
        $this->adapter->setCommandArray($this->commandArray);
        $result = $this->adapter->execute();
        $commandArrayUsed = $this->adapter->getCommandArray();
        $this->clearCommandArray();
        $this->checkResultForError($result, $commandArrayUsed);
        return $result;
    }
536882
private function execute()
    {
        $this->connect();
        try {
            $this->getSyntax();
            $this->command->execute();

            if (preg_match('/^(SELECT|SHOW) /i', $this->select))
                $this->result = $this->command->fetchAll();

        } catch (\PDOException $e) {
            $this->result = "<b>Erro ao Executar Comando: </b> {$e->getMessage()}";
            $this->erro = "<b>Erro ao Executar Comando</b> {$e->getMessage()}";
        }

        parent::setDefault();
    }