Makes request to MogileFS tracker.

@param cmd Command
@param args Array of arguments

@return mixed Array on success, false on failure
432791
private function doRequest($cmd, $args = array())
    {
        clearstatcache();
        $args['domain'] = $this->domain;
        $params = http_build_query($args);

        $this->connect();

        fwrite($this->socket, "{$cmd} {$params}\n");
        $line = fgets($this->socket);

        $words = explode(' ', $line);

        if ($words[0] == 'OK') {
            parse_str(trim($words[1]), $result);
        } else {
            $errorName = empty($words[1]) ? null : $words[1];

            switch ($errorName) {
                case 'unknown_key':
                    $errorCode = static::ERR_UNKNOWN_KEY;
                    break;
                case 'empty_file':
                    $errorCode = static::ERR_EMPTY_FILE;
                    break;
                case 'none_match':
                    $errorCode = static::ERR_NONE_MATCH;
                    break;
                case 'key_exists':
                    $errorCode = static::ERR_KEY_EXISTS;
                    break;
                default:
                    $errorCode = static::ERR_OTHER;
            }

            throw new \RuntimeException(
                sprintf('Error response: %s', $line),
                $errorCode
            );
        }

        return $result;
    }
153978
private function buildCommand($cmd, $args = array()) {
    while(list($name, $data) = each($args)) {
    $safeData = false;
      $filterType = mb_substr($name, 0, 1);
      switch($filterType) {
        case '%':
          $safeData = escapeshellarg($data);
          break;
        case '!':
          $safeData = escapeshellcmd($data);
          break;
        default:
          throw new \phpSec\Exception\InvalidArgumentException('Unknown variable type');
          break;
      }
      if($safeData !== false) {
        $cmd = str_replace($name, $safeData, $cmd);
      }
    }
    return $cmd;
  }
1287828
public function helperExec($cmd)
    {
        if ($this->resolve('EXPLAIN')) {
            $this->output->writeln("# Task needs the following helper command:");
            $this->output->writeln("# " . str_replace("\n", "\\n", $cmd));
        }
        $ret = '';
        $this->executor->execute($cmd, $ret);
        return $ret;
    }
524932
public function autoscan($cmd, $args = [], $cbEnd = null, $limit = null)
    {
        return new AutoScan($this, $cmd, $args, $cbEnd, $limit);
    }
760578
public function
	Run($cmd=null) {
	/*//
	@argv string HandlerName
	@argv array CommandArgumentList

	if given a string it will execute the handler defined under as that name.
	if given an array then it will process that array as though it was the
	_SERVER['argv'] data and execute as if that was the original command line
	given to the object creation.
	//*/

		$restore = false;
		$return = 0;

		////////
		////////

		if(is_array($cmd)) {
			// rewrite our input and option data with this subcommand
			// that was given to us. execute as though this array defined
			// the original command input.

			$restore = [ 'Inputs'=>$this->Inputs, 'Options'=>$this->Options ];

			$data = static::ParseCommandArgs($cmd,false);
			$this->Inputs = $data['Inputs'];
			$this->Options = $data['Options'];

			$cmd = $this->GetInputs();
		}

		////////
		////////

		if(!$cmd && !($cmd = $this->GetInput(1))) {
			if(!$this->DefaultHandlerName) {
				echo "No input provided.", PHP_EOL;
				return static::ErrorNoInput;

			}

			$cmd = [$this->DefaultHandlerName];
		}

		else {
			$cmd = $this->GetInputs();
		}

		////////
		////////

		$Commanded = FALSE;

		foreach($cmd as $cur) {
			$method = static::GetMethodFromCommand($cur);
			try {
				$return = $this->Run_ByMethod($method);
				$Commanded = TRUE;
			}
			catch(ClientHandlerException $e) {
				try {
					$return = $this->Run_ByCallable($cur);
					$Commanded = TRUE;
				}
				catch(ClientHandlerException $e) { }
			}

			if($Commanded && !$this->ChainCommands)
			break;
		}

		if(!$Commanded) {
			echo "no handler or method found for {$cur}", PHP_EOL;
			return static::ErrorNoHandler;
		}

		////////
		////////

		if($restore) {
			// restore the original input data before continuing on so that
			// we could continue processing the cli input data if needed.
			$this->Inputs = $restore['Inputs'];
			$this->Options = $restore['Options'];
		}

		return $return;
	}
489369
protected function getCommand($cmd, $tokens)
    {
        return Template::parse($cmd, $tokens, '%%', '%%', Template::FLAG_RECURSIVE | Template::FLAG_EMPTY_MISSING);
    }
449950
private function searchForExecutable($cmd)
    {
        $nodeModules = $this->findNodeModules();
        if ($nodeModules) {
            $finder = new Finder();
            $finder->files()->in($nodeModules)->name($cmd);
            foreach ($finder as $executable) {
                return $executable->getRealPath();
            }
        }
        $execFinder = new ExecutableFinder();
        return $execFinder->find($cmd, null, []);
    }
107175
private function Run_Cmd($_cmd, $_args = '')
    {
        if ( $_args != '' )
        {
            if ( $_cmd == '' ) $_cmd = $_args;
            else $_cmd = $_cmd." ".$_args;
            //$_cmd == ''?$_cmd = $_args:$_cmd." ".$_args;
        }

        fputs($this->Smtp_Socket, $_cmd."\r\n");
        return $this->Smtp_Ok();  //return the response code
    }
760594
function cmd_MKD($fd, $cmd)
    {
        $user = $this->getUser($fd);
        $path = $this->getAbsDir($user).$cmd[1];

        if (!is_dir(dirname($path)))
        {
            $this->send($fd, "550 Can't create directory: No such file or directory");
        }
        elseif(file_exists($path))
        {
            $this->send($fd, "550 Can't create directory: File exists");
        }
        else
        {
            if (mkdir($path))
            {
                $this->send($fd, "257 \"" . $cmd[1] . "\" : The directory was successfully created");
            }
            else
            {
                $this->send($fd, "550 Can't create directory: Permission denied");
            }
        }
    }
548507
public function executeCommand($cmd)
    {
        $this->checkConnected();

        $write = @fwrite($this->socket, "$cmd\r\n");
        if (false === $write) {
            throw new Exception\IOError('Error while writing to the Tor server');
        }

        $data = [];
        while (true) {
            $response = fread($this->socket, 1024);

            $multiline = false;
            $last_code = null;
            $last_separator = null;
            foreach (explode("\r\n", $response) as $line) {
                $code = substr($line, 0, 3);
                $separator = substr($line, 3, 1);
                $message = substr($line, 4);

                if ('+' === $separator) {
                    $multiline = true;
                    $last_code = $code;
                    $last_separator = $separator;
                }

                if ($multiline) {
                    $data[] = [
                        'code' => $last_code,
                        'separator' => $last_separator,
                        'message' => $line,
                    ];
                } else {
                    if (false === $code || false === $separator) {
                        $e = new Exception\ProtocolError('Bad response format');
                        $e->setResponse($response);

                        throw $e;
                    }

                    if (!in_array($separator, [' ', '+', '-'])) {
                        $e = new Exception\ProtocolError('Unknown separator');
                        $e->setResponse($response);

                        throw $e;
                    }

                    if (!in_array(substr($code, 0, 1), ['2', '6'])) {
                        $e = new Exception\TorError($message, $code);
                        $e->setResponse($response);

                        return $e;
                    }

                    $data[] = [
                        'code' => $code,
                        'separator' => $separator,
                        'message' => $message,
                    ];
                }

                if (' ' === $separator) {
                    break 2;
                }
            }
        }

        return $data;
    }
233323
function (cmd) {
			return self.alreadyProcessedTraces[cmd.modelElement.path()] && self.alreadyProcessedTraces[cmd.modelElement.path()][cmd.toString()];
		}
219983
private function getCmd(array $args)
    {
        // get path to console from kernel..
        $consolePath = $this->kernel->getRootDir() . '/console';

        // this code was copied from Symfony\Component\Process\PhpProcess and deserves a cleanup
        $executableFinder = new PhpExecutableFinder();
        if (false === $php = $executableFinder->find()) {
            $php = null;
        }
        if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
            // exec is mandatory to deal with sending a signal to the process
            // see https://github.com/symfony/symfony/issues/5030 about prepending
            // command with exec
            $php = 'exec '.$php;
        }

        $cmd = $php.' '.$consolePath.' -n ';

        foreach ($args as $key => $val) {
            if (strlen($key) > 1) {
                $cmd .= ' ' . $key;
            }
            if (strlen($key) > 1 && !is_null($val)) {
                $cmd .= '=';
            }
            if (strlen($val) > 1) {
                $cmd .= escapeshellarg($val);
            }
        }

        return $cmd;
    }
875052
public function command_args(CommandInterface $cmd, $cmdSignature)
    {
        $args = [];
        $arguments = $cmd->getArguments();

        // for command that does not define an argument, we just complete the argument by file paths.
        if ($arguments === []) {
            return ['*:default:_files'];
        }

        $idx = 0;
        foreach ($arguments as $a) {
            $comp = '';

            if ($a->multiple) {
                $comp .= '*:' . $a->name;
            } else {
                $comp .= ':' . $a->name;
            }

            if ($a->validValues || $a->suggestions) {
                if ($a->validValues) {
                    if (is_callable($a->validValues)) {
                        $comp .= ':{' . implode(' ', [
                                $this->meta_command_name(),
                                Util::qq($a->name),
                                $cmdSignature,
                                'arg',
                                $idx,
                                'valid-values',
                            ]) . '}';
                    } elseif ($values = $a->getValidValues()) {
                        $comp .= ':(' . implode(' ', Util::array_qq($values)) . ')';
                    }
                } elseif ($a->suggestions) {
                    if (is_callable($a->suggestions)) {
                        $comp .= ':{' . implode(' ', [
                                $this->meta_command_name(),
                                Util::qq($a->name),
                                $cmdSignature,
                                'arg',
                                $idx,
                                'suggestions',
                            ]) . '}';
                    } elseif ($values = $a->getSuggestions()) {
                        $comp .= ':(' . implode(' ', Util::array_qq($values)) . ')';
                    }
                }
            } elseif (in_array($a->isa, ['file', 'path', 'dir'], true)) {
                switch ($a->isa) {
                    case 'file':
                        $comp .= ':_files';
                        break;
                    case 'path':
                        $comp .= ':_path_files';
                        break;
                    case 'dir':
                        $comp .= ':_directories';
                        break;
                }
                if ($a->glob) {
                    $comp .= " -g \"{$a->glob}\"";
                }
            }
            $args[] = Util::q($comp);
            $idx++;
        }

        return empty($args) ? null : $args;
    }
64772
public static function findCommandLong($arg) {
		foreach (self::$commands as $command => $commandOptions) {
			if (($commandOptions["commandLong"] == $arg) || ($commandOptions["commandShort"] == $arg)) {
				return $command;
			}
		}
		return false;
	}
58357
public static function run($cmd)
    {
        self::initEvn();

        $param = is_array($cmd) && count($cmd) == 2 ? $cmd[1] : $cmd;
        switch ($param) {
            case 'start':
                self::start();
                break;
            case 'stop':
                self::stop();
                break;
            case 'reload':
                self::reload();
                break;
            case 'status':
                self::getStatus(true);
                break;
            case 'add-task':
                if (func_num_args() < 1) {
                    self::message('please input task name');
                    break;
                }
                $args = func_get_args();
                $frequency = isset($args[2]) ? intval($args[2]) : 60;
                self::addTask($args[1], $frequency);
                break;
            case 'rm-task':
                if (func_num_args() < 1) {
                    self::message('please input task name');
                    break;
                }
                $args = func_get_args();
                self::rmTask($args[1]);
                break;
            default:
                self::message('Usage: xxx.php cml.cmd DaemonWorker::run {start|stop|status|addtask|rmtask}');
                break;
        }
    }
995247
public static function make( $cmd, $params )
	{
		if ( !is_array( $params ) )
		{
			$params = array( $params );
		}
		
		$forge = new static;
		
		if ( !method_exists( $forge, $cmd ) )
		{
			throw new CCException( "CCForge_Php - Command could not be found." );
		}
		
		return call_user_func_array( array( $forge, $cmd ), $params );
	}
410790
public function run(String $cmd = NULL)
    {
        $this->createExecFileIfNotExists();

        $this->addJobToExecFile($cmd);
        
        return $this->executeCommand();
    }