当前位置: 首页>>代码示例>>PHP>>正文


PHP Shell类代码示例

本文整理汇总了PHP中Shell的典型用法代码示例。如果您正苦于以下问题:PHP Shell类的具体用法?PHP Shell怎么用?PHP Shell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Shell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Executo command on shell
  * @param Shell $shell
  * @return bool
  * @throws \Exception
  */
 public function run(Shell $shell)
 {
     $match = NULL;
     while (true) {
         fwrite($shell->getStream(), $this->__cmd);
         switch ($key = expect_expectl($shell->getStream(), $cases = $this->formatCases(), $match)) {
             case in_array($key, $cases):
                 // Run next
                 if ($this->__next instanceof TCommand) {
                     $this->__next->run($shell);
                 }
                 if ('break' == ($result = $this->__cases_list[$key]->proceed($shell->getStream(), $match))) {
                     break;
                 }
                 $shell->addCmd($this->__cmd);
                 $shell->addResult($this->formatResult($result));
                 return true;
                 break 2;
             case EXP_EOF:
             case EXP_FULLBUFFER:
                 break 2;
             case EXP_TIMEOUT:
                 throw new \Exception("Connection time out");
                 break 2;
             default:
                 throw new \Exception("Error has occurred!");
                 break 2;
         }
     }
     return false;
 }
开发者ID:nejtr0n,项目名称:expect,代码行数:37,代码来源:Command.php

示例2: testCount

 public function testCount()
 {
     $gerador = new Gerador();
     $vector = $gerador->gerar(500);
     $shell = new Shell();
     $array = Asort($vector);
     $this->assertEquals($array, $shell->run($vector));
 }
开发者ID:secretrepository,项目名称:algbuild,代码行数:8,代码来源:CommandTest.php

示例3: testProjectDir

 public function testProjectDir()
 {
     $projectDir = __DIR__ . '/../../../../';
     $shell = new Shell($projectDir);
     $testCommand = 'vendor/bin/phpunit';
     $result = $shell->exec($testCommand, ['--version']);
     $this->assertContains('PHPUnit', $result);
 }
开发者ID:cakmoel,项目名称:QualityAnalyzer,代码行数:8,代码来源:ShellTest.php

示例4: truncateModels

 /**
  * Truncate the given models
  *
  * @param array $modelsToTruncate An array of models (names) to truncate
  * @return void
  * @todo Improve testability by extracting the model object retrieval part.
  */
 public function truncateModels($modelsToTruncate)
 {
     foreach ($modelsToTruncate as $modelName) {
         $this->_shell->out(__('Truncate model %s...', $modelName), 1, Shell::VERBOSE);
         $model = ClassRegistry::init($modelName);
         $datasource = $model->getDataSource();
         $datasource->truncate($model->table);
     }
 }
开发者ID:ravage84,项目名称:cakephp-fake-seeder,代码行数:16,代码来源:ShellModelTruncator.php

示例5: parseFile

 /**
  * Parse file
  * @param string $Filename relative path (from FRONTEND_PATH) to file
  */
 public function parseFile($Filename)
 {
     $File = FRONTEND_PATH . $Filename;
     $this->Filename = FRONTEND_PATH . $Filename . '.temp';
     $Command = new PerlCommand();
     $Command->setScript('fittorunalyze.pl', '"' . $File . '" 1>"' . $this->Filename . '"');
     $Shell = new Shell();
     $Shell->runCommand($Command);
     $this->readFile();
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:14,代码来源:class.ImporterFiletypeFIT.php

示例6: isPerlAvailable

 /**
  * Is Perl available?
  * 
  * Tries to run a testscript and returns true if succeeded.
  * @return boolean
  */
 public static function isPerlAvailable()
 {
     try {
         $Command = new PerlCommand();
         $Command->setScript('test.pl', '');
         $Shell = new Shell();
         $Shell->runCommand($Command);
         return $Shell->getOutput() == 'success';
     } catch (Exception $Exception) {
         return false;
     }
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:18,代码来源:class.Shell.php

示例7: doShell

 /**
  * Handle the run shell action
  * @return ShellResult
  */
 public function doShell()
 {
     // $shell is derived from RunResult
     $shell = new Shell();
     while (!$shell->isEOF()) {
         if ($shell->isFail()) {
             break;
         }
         $input = $shell->readInput();
         if ($input === FALSE) {
             break;
         }
         // Available shell commands (for help sreen)
         $shell_commands = array('dump', 'exit', 'help');
         // Interpret shell keywords
         switch ($input) {
             case 'exit':
                 break 2;
             case 'dump':
                 $this->stdout(print_r($this->getMemory()->getData(), true));
                 break;
             case 'help':
                 $extension_manager = $this->getExtensionManager();
                 $exports = $extension_manager->exports();
                 $this->stdout(PHP_EOL);
                 $this->stdout(str_pad(' Commands:', 13) . join(', ', $shell_commands) . PHP_EOL);
                 $this->stdout(str_pad(' Keywords:', 13) . join(', ', $this->getLanguageKeywords()) . PHP_EOL);
                 $this->stdout(str_pad(' Functions:', 13) . join(', ', $exports) . PHP_EOL);
                 $this->stdout(PHP_EOL);
                 break;
             default:
                 // Assume is code
                 $this->setCode($input);
                 $result = $this->doRun();
                 // TODO: Finished this
                 // dd($result);
                 // $this->stdout()
                 // Handle printing errors
                 if ($result->isFail()) {
                     foreach ($result->getErrors() as $error) {
                         $this->stderr($this->outputFormatErrorMessage($error));
                     }
                 }
                 break;
         }
         // TODO: Provide interface for setting position :/
         $this->line++;
         $this->column = 0;
     }
     $shell->setData($this->getMemory()->getData());
     return $shell;
 }
开发者ID:g4z,项目名称:poop,代码行数:56,代码来源:Interpreter.php

示例8: instance

 public static function instance()
 {
     if (!self::$_instance instanceof Shell) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:7,代码来源:class.shell.php

示例9: execute

 /**
  * Executa comando
  *
  * @param Object $oInput
  * @param Object $oOutput
  * @access public
  * @return void
  */
 public function execute($oInput, $oOutput)
 {
     $oOutput->write("baixando atualizações...\r");
     $oComando = $this->getApplication()->execute('cvs update -dRP');
     $aRetornoComandoUpdate = $oComando->output;
     $iStatusComandoUpdate = $oComando->code;
     /**
      * Caso CVS encontre conflito, retorna erro 1
      */
     if ($iStatusComandoUpdate > 1) {
         $oOutput->writeln('<error>Erro nº ' . $iStatusComandoUpdate . ' ao execurar cvs update -dR:' . "\n" . $this->getApplication()->getLastError() . '</error>');
         return $iStatusComandoUpdate;
     }
     $oOutput->writeln(str_repeat(' ', \Shell::columns()) . "\r" . "Atualizações baixados");
     $sComandoRoot = '';
     /**
      * Senha do root
      */
     $sSenhaRoot = $this->getApplication()->getConfig('senhaRoot');
     /**
      * Executa comando como root 
      * - caso for existir senha no arquivo de configuracoes
      */
     if (!empty($sSenhaRoot)) {
         $sComandoRoot = "echo '{$sSenhaRoot}' | sudo -S ";
     }
     $oComando = $this->getApplication()->execute($sComandoRoot . 'chmod 777 -R ' . getcwd());
     $aRetornoComandoPermissoes = $oComando->output;
     $iStatusComandoPermissoes = $oComando->code;
     if ($iStatusComandoPermissoes > 0) {
         throw new Exception("Erro ao atualizar permissões dos arquivos, configura a senha do root: cvsgit config -e");
     }
 }
开发者ID:renanrmelo,项目名称:cvsgit,代码行数:41,代码来源:PullCommand.php

示例10: _run

 /**
  * Runs task
  */
 protected function _run()
 {
     $this->_Process = new TaskProcess($this->_task['command'] . $this->_argsToString($this->_task['arguments']), $this->_task['path']);
     $this->_Process->setTimeout($this->_task['timeout']);
     try {
         $this->_Process->start(function ($type, $buffer) {
             if ('err' === $type) {
                 $this->_Shell->err($buffer);
                 $this->_task['stderr'] .= $buffer;
             } else {
                 $this->_Shell->out($buffer);
                 $this->_task['stdout'] .= $buffer;
             }
             $this->_TaskServer->updated($this->_task);
         });
         while ($this->_Process->isRunning()) {
             $this->_task['process_id'] = (int) $this->_Process->getPid();
             $this->_TaskServer->updateStatistics($this->_task);
             $this->_Process->checkTimeout();
             sleep(Configure::read('Task.checkInterval'));
             if ($this->_TaskServer->mustStop($this->_task['id'])) {
                 $this->_Process->stop(Configure::read('Task.stopTimeout'));
                 $this->_task['code'] = 143;
                 $this->_task['code_string'] = TaskProcess::$exitCodes[143];
                 return $this->_stopped(true);
             }
         }
         $this->_task['code'] = $this->_Process->getExitCode();
         $this->_task['code_string'] = $this->_Process->getExitCodeText();
     } catch (Exception $Exception) {
         $this->_task['code'] = 134;
         $this->_task['code_string'] = $Exception->getMessage();
     }
     $this->_stopped(false);
 }
开发者ID:imsamurai,项目名称:cakephp-task-plugin,代码行数:38,代码来源:TaskRunner.php

示例11: main

 function main()
 {
     parent::loadTasks();
     $this->out('Import Upload Shell');
     $this->hr();
     $this->_setAvailableImportFiles();
     if (empty($this->args)) {
         $imports = $this->_interactive();
     } else {
         $imports = $this->_determineImportIds(implode(' ', $this->args));
     }
     if (!empty($imports)) {
         foreach ($imports as $import) {
             $importUpload = $this->ImportUpload->create($import);
             if ($filename = $this->ImportUpload->filePath()) {
                 $importUpload['ImportUpload']['file_path'] = $filename;
                 if (!empty($import['ImportDelimiter'])) {
                     $options = array('delimiter' => $import['ImportDelimiter']['delimiter'], 'excel_reader' => $import['ImportDelimiter']['use_excel_reader'], 'qualifier' => $import['ImportUpload']['text_qualifier']);
                 }
                 if ($this->Parser->execute($filename, $options)) {
                     $this->ImportUpload->saveField('total', $this->Parser->getRowCount());
                     $this->ImportUpload->saveField('is_importing', 1);
                 }
                 die('here');
             } else {
             }
         }
     }
 }
开发者ID:nicoeche,项目名称:Finalus,代码行数:29,代码来源:import_upload.php

示例12: read

 /**
  * @param array $args
  *
  * @return array
  */
 public function read($args = [])
 {
     $args = $this->processOptions($args);
     $this->shell->exec('git fetch -u');
     $this->shell->exec("git log {$args['revision range']} --pretty=format:%s", $output);
     return $output;
 }
开发者ID:elsuperbeano,项目名称:curator,代码行数:12,代码来源:SimpleGitReader.php

示例13: testTruncateModels

 /**
  * Tests the truncateModels function
  *
  * @return void
  * @covers ::truncateModels
  */
 public function testTruncateModels()
 {
     $this->_shell->expects($this->at(0))->method('out')->with($this->equalTo('Truncate model Apple...'));
     $this->_shell->expects($this->at(1))->method('out')->with($this->equalTo('Truncate model Banana...'));
     $this->_shell->expects($this->at(2))->method('out')->with($this->equalTo('Truncate model Pear...'));
     $models = array('Apple', 'Banana', 'Pear');
     $this->_truncator->truncateModels($models);
 }
开发者ID:ravage84,项目名称:cakephp-fake-seeder,代码行数:14,代码来源:ShellModelTruncatorTest.php

示例14: read

 /**
  * @param array $args
  *
  * @return array
  */
 public function read($args = [])
 {
     $args = $this->processOptions($args);
     $delim = "---<EOM>---";
     $command = "git log {$args['revision range']} --pretty=format:\"{$this->format}{$delim}\"";
     $output = substr($this->shell->shell_exec($command), 0, -1 * strlen($delim . PHP_EOL));
     $output = explode(PHP_EOL . $delim . PHP_EOL, $output);
     return $output;
 }
开发者ID:elsuperbeano,项目名称:curator,代码行数:14,代码来源:GitReader.php

示例15: getOptionParser

 /**
  * Add sub-commands.
  *
  * @return ConsoleOptionParser
  */
 public function getOptionParser()
 {
     $parser = parent::getOptionParser();
     $parser->addSubcommand('core', array('help' => 'Delete all cache within CakePHP', 'parser' => array('description' => 'This command will clear all cache in CakePHP using the Cache engine settings.', 'options' => array('config' => array('short' => 'c', 'help' => 'Cache Config', 'default' => 'default'), 'key' => array('short' => 'k', 'help' => 'Cache Key', 'default' => '')))));
     $parser->addSubcommand('apc', array('help' => 'Delete all cache within APC', 'parser' => array('description' => 'This command will clear all cache in APC, including user, system and opcode caches.')));
     return $parser;
 }
开发者ID:alescx,项目名称:cakephp-utils,代码行数:12,代码来源:CacheKillShell.php


注:本文中的Shell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。