當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。