Submit a command
@param array $command
@param array $args
@return array
187377
public function submit(array $command, array $args)
    {
        $result = (array) $this->callHandler($command, 'submit', $args);
        $result += array('redirect' => '', 'message' => '', 'severity' => '');
        return $result;
    }
271894
public function command(string $command, string $args = null, int $expect = 0): string
    {
        $sendCommand = $args ? sprintf('%1$s %2$s', $command, $args) : $command;
        $this->write($sendCommand);
        $response = $this->read();
        $responseCode = $this->lastResponseCode();

        if ($expect > 0) {
            if ($responseCode !== $expect) {
                throw SMTPException::unexpectedResponse($command, $expect, $responseCode);
            }
        }

        return $response;
    }
233457
private synchronized void submit(final String command) {
    LOG.log(Level.INFO, "Submit command {0} to {1} evaluators. state: {2}",
        new Object[]{command, this.contexts.size(), this.state});
    assert this.state == State.READY;
    this.expectCount = this.contexts.size();
    this.state = State.WAIT_TASKS;
    this.cmd = null;
    for (final ActiveContext context : this.contexts.values()) {
      this.submit(context, command);
    }
  }
335587
public function execute($command, $arguments = array())
    {
        $options = $this->getOptions();
        $consoleDir = $this->getConsoleDir();

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

        $argumentString = '';

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

        $this->executeCommand($consoleDir, $command . ' ' . $argumentString);
    }
843130
protected function send($command, array $arguments)
    {
        $event = $this->prepareEvent($command, $arguments);

        // The last arguments of call_user_func_array must not be null
        if (end($arguments) === null) {
            array_pop($arguments);
        }

        $retry = $this->maxRetry;
        while ($retry >= 0) {
            try {
                $return = call_user_func_array([$this->getSession(), $command], $arguments);

                // No exception, we can return the result
                $retry = -1;
            } catch (\Cassandra\Exception\RuntimeException $e) {
                if ($retry > 0) {
                    // Reset the current session to retry the command
                    $this->resetSession();
                    $retry--;
                } else {
                    // too many retries, rethrow the exception
                    throw $e;
                }
            }
        }

        return $this->prepareResponse($return, $event);
    }
915479
private function process($command, array $data = [])
    {
        return $this->parse(
            $this->cURL(
                $this->queryString(
                    array_merge([
                        'command' => $command
                    ], $data)
                )
            )
        );
    }
876281
protected function getKeyFromBlockingListCommands(string $command, array $arguments)
    {
        if ($this->checkSameSlotForKeys(\array_slice($arguments, 0, \count($arguments) - 1))) {
            return $arguments[0];
        }

        return null;
    }
911536
public function writeCommand($command, $args = [])
    {
        $output = $this->getOutput();
        if ($output->getLevel(LogLevel::INFO) < $output->getLevel()) {
            return;
        }

        if (count($args)) {
            $outArr = [];
            foreach ($args as $arg) {
                if (is_array($arg)) {
                    $arg = array_map(
                        function ($value) {
                            return '\'' . $value . '\'';
                        },
                        $arg
                    );
                    $outArr[] = '[' . implode(', ', $arg) . ']';
                    continue;
                }

                $outArr[] = '\'' . $arg . '\'';
            }
            $output->info(' -- ' . $command . '(' . implode(', ', $outArr) . ')');

            return;
        }

        $output->info(' -- ' . $command);
    }
200514
public function executeCommand($args = array())
    {
        $this->lastOutput = array();

        $command = call_user_func_array('sprintf', $args);
        $this->logger->logDebug($command);

        if ($this->quiet) {
            $this->logger->log('Executing: ' . $command);
        }

        $status = 0;
        $descriptorSpec = array(
            0 => array("pipe", "r"),  // stdin
            1 => array("pipe", "w"),  // stdout
            2 => array("pipe", "w"),  // stderr
        );

        $pipes = array();
        $process = proc_open($command, $descriptorSpec, $pipes, $this->buildPath, null);

        if (is_resource($process)) {
            fclose($pipes[0]);

            stream_set_blocking($pipes[1], 0);
            stream_set_blocking($pipes[2], 0);

            $lastOutput = '';
            $lastError  = '';
            do {
                usleep(200); //Give It Time To Start

                while (($newData = fread($pipes[1], 1024)) && !feof($pipes[1])) {
                    $lastOutput .= $newData;
                }

                while (($newData = fread($pipes[2], 1024)) && !feof($pipes[2])) {
                    $lastError .= $newData;
                }

                $processStatus = proc_get_status($process);
            } while ($processStatus['running']);

            $this->lastOutput = $lastOutput;
            $this->lastError  = $lastError;

            fclose($pipes[1]);
            fclose($pipes[2]);

            proc_close($process);
            $status = $processStatus['exitcode'];
        }

        $this->lastOutput = array_filter(explode(PHP_EOL, $this->lastOutput));

        $shouldOutput = ($this->logExecOutput && ($this->verbose || $status != 0));

        if ($shouldOutput && !empty($this->lastOutput)) {
            $this->logger->log($this->lastOutput);
        }

        if (!empty($this->lastError)) {
            $this->logger->log("\033[0;31m" . $this->lastError . "\033[0m", LogLevel::ERROR);
        }

        $rtn = false;

        if ($status == 0) {
            $rtn = true;
        }

        return $rtn;
    }
312917
protected function executeRun(array $command)
    {
        // Output will be written to a temporary stream, so that it can be
        // collected after running the command.
        $stream = fopen('php://temp', 'w+');

        // Execute the command, capturing the output in the temporary stream
        // and storing the exit code for debugging purposes.
        $this->exit_code = $this->app->doRun(new ArrayInput($command), new StreamOutput($stream));

        // Get the output of the command and close the stream, which will
        // destroy the temporary file.
        $result = stream_get_contents($stream, -1, 0);
        fclose($stream);

        return $result;
    }
1107523
private function executeCommand(array $command, array $options)
    {
        return $this
            ->getCommandExecutor()
            ->executeCommand(
                $this->manager,
                $this->databaseName,
                $command,
                $options
            );
    }
1128137
public static function escape(array $args): string
  {
    $command = '';
    foreach ($args as $arg)
    {
      if ($command!='') $command .= ' ';
      $command .= escapeshellarg($arg);
    }

    return $command;
  }
515346
public function getOrCreateIfNotExists($command, array $args = [])
    {
        if (null !== $job = $this->findJob($command, $args)) {
            return $job;
        }

        $job = new Job($command, $args, false);
        $this->_em->persist($job);
        $this->_em->flush($job);

        $firstJob = $this->_em->createQuery('SELECT j FROM JMSJobQueueBundle:Job j WHERE j.command = :command AND j.args = :args ORDER BY j.id ASC')
            ->setParameter('command', $command)
            ->setParameter('args', $args, 'json_array')
            ->setMaxResults(1)
            ->getSingleResult();

        if ($firstJob === $job) {
            $job->setState(Job::STATE_PENDING);
            $this->_em->persist($job);
            $this->_em->flush($job);

            return $job;
        }

        $this->_em->remove($job);
        $this->_em->flush($job);

        return $firstJob;
    }
1174977
public function commandFor(array $argv): Command
    {
        $argv += [null, null, null];

        return
             // cmd
            $this->commands[$argv[1]]
            // cmd alias
            ?? $this->commands[$this->aliases[$argv[1]] ?? null]
            // default.
            ?? $this->commands[$this->default];
    }
20736
public function call( $command, array $parameters = [] )
	{
		$parameters = collect( $parameters )->prepend( $command );

		$this->lastOutput = new BufferedOutput;

		$this->setCatchExceptions( false );

		$result = $this->run( new ArrayInput( $parameters->toArray() ), $this->lastOutput );

		$this->setCatchExceptions( true );

		return $result;
	}
95212
private function send(string $method, string $command, array $options = []): array 
    {
        $result = $this->client->da_request($method, self::CMD_PREFIX . $command, $options);
        
        return $result;
    }
1168667
public function getJob($command, array $args = [])
    {
        if (null !== $job = $this->findJob($command, $args)) {
            return $job;
        }

        throw new \RuntimeException(sprintf('Found no job for command "%s" with args "%s".', $command, json_encode($args)));
    }