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


PHP Shell::execute方法代码示例

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


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

示例1: execute

 public function execute($message)
 {
     global $pluginManager;
     global $t;
     $t->setPlugin("netutils");
     $reply = "";
     $data = $message->getData();
     $shell = new Shell();
     $execute = true;
     $call = $message->getCommand();
     array_shift($data);
     switch ($call) {
         case "nslookup":
             $shell->setFilter(array("main" => "nslookup", "subarg" => array()));
             $cmd = "nslookup " . implode(" ", $data);
             break;
         case "dig":
             $shell->setFilter(array("main" => "dig", "subarg" => array()));
             $cmd = "dig " . implode(" ", $data);
             break;
         case "nmap":
             $shell->setFilter(array("main" => "nmap", "subarg" => array()));
             $cmd = "nmap " . implode(" ", $data);
             break;
         case "whois":
             $shell->setFilter(array("main" => "whois", "subarg" => array()));
             $cmd = "whois " . implode(" ", $data);
             break;
         default:
             $reply = $t->g("default");
             $execute = false;
             break;
     }
     if ($execute) {
         $shell->setCmd($cmd);
         if ($shell->execute()) {
             $reply = "`\$ " . api::encodePlain($cmd) . "\n" . api::encodePlain(implode("\n", $shell->getOutput())) . "`";
         } else {
             $reply = sprintf($t->g("command_error"), api::encodePlain($cmd));
         }
     }
     // Api::reply($message, $reply, true);
     global $api;
     $api->sendMessage($message->chat->id, $reply, "Markdown", true);
 }
开发者ID:kryptur,项目名称:telegramBot,代码行数:45,代码来源:plugin.php

示例2: applyRemoteChanges

 /**
  * Applies changes from remote repository.
  * @param string $projectRoot VCS project root directory path.
  * @param string $log if parameter passed it will be filled with related log string.
  * @return boolean whether the changes have been applied successfully.
  */
 public function applyRemoteChanges($projectRoot, &$log = null)
 {
     $result = Shell::execute('(cd {projectRoot}; {binPath} pull -b {branch} -u)', ['{binPath}' => $this->binPath, '{projectRoot}' => $projectRoot, '{branch}' => $this->getCurrentBranch($projectRoot)]);
     $log = $result->toString();
     return $result->isOk();
 }
开发者ID:jacmoe,项目名称:yii2-mdpages-module,代码行数:12,代码来源:Mercurial.php

示例3: test_failure

 public function test_failure()
 {
     $s = new Shell();
     $result = $s->execute('exit 4', $output);
     $this->assertEquals(4, $result);
 }
开发者ID:oktopost,项目名称:aquarium,代码行数:6,代码来源:ShellTest.php


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