本文整理汇总了PHP中exec函数的典型用法代码示例。如果您正苦于以下问题:PHP exec函数的具体用法?PHP exec怎么用?PHP exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSymbolicLink
public static function createSymbolicLink($rootDir = null)
{
IS_MULTI_MODULES || exit('please set is_multi_modules => true');
$deper = Request::isCli() ? PHP_EOL : '<br />';
echo "{$deper}**************************create link start!*********************{$deper}";
echo '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
is_null($rootDir) && ($rootDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web');
is_dir($rootDir) || mkdir($rootDir, true, 0700);
//modules_static_path_name
// 递归遍历目录
$dirIterator = new \DirectoryIterator(APP_MODULES_PATH);
foreach ($dirIterator as $file) {
if (!$file->isDot() && $file->isDir()) {
$resourceDir = $file->getPathName() . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name');
if (is_dir($resourceDir)) {
$distDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $file->getFilename();
$cmd = Request::operatingSystem() ? "mklink /d {$distDir} {$resourceDir}" : "ln -s {$resourceDir} {$distDir}";
exec($cmd, $result);
$tip = "create link Application [{$file->getFilename()}] result : [" . (is_dir($distDir) ? 'true' : 'false') . "]";
$tip = str_pad($tip, 64, ' ', STR_PAD_BOTH);
print_r($deper . '|' . $tip . '|');
}
}
}
echo $deper . '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
echo "{$deper}****************************create link end!**********************{$deper}";
}
示例2: shareBugglAction
public function shareBugglAction(Request $request)
{
$prevEmails = '';
$invalidMessage = '';
if ($request->isMethod('POST')) {
$invalidEmails = array();
$validEmails = array();
$prevEmails = $request->request->get('emails', '');
$localReferenceService = $this->get('buggl_main.local_reference_service');
$validationData = $localReferenceService->validateEmails($prevEmails);
$invalidMessage = $validationData['invalidMessage'];
if (empty($invalidMessage)) {
$shareService = $this->get('buggl_main.share');
$user = $this->get('security.context')->getToken()->getUser();
foreach ($validationData['validEmails'] as $key => $email) {
$share = $shareService->saveShareInfo($email, $user);
}
$prevEmails = '';
exec('../app/console buggl:email_shares > /dev/null 2>&1 &');
$streetCreditService = $this->get('buggl_main.street_credit');
$streetCreditService->updateShareStatus($user);
$this->get('session')->getFlashBag()->add('success', "Emails sent!");
}
}
$localAuthor = $this->get('security.context')->getToken()->getUser();
//$streetCredit = $this->getDoctrine()->getRepository("BugglMainBundle:StreetCredit")->findOneByLocalAuthor($localAuthor);
$newEGuideRequestCount = $this->getDoctrine()->getEntityManager()->getRepository('BugglMainBundle:MessageToUser')->countRequestByStatus($localAuthor, array('0' => '0'));
$data = array('invalidMessage' => $invalidMessage, 'prevEmails' => $prevEmails, 'newRequestCount' => $newEGuideRequestCount);
return $this->render('BugglMainBundle:LocalAuthor\\EarnMore:shareBuggl.html.twig', $data);
}
示例3: getApertureFields
/**
* Load metadata about an HTML document using Aperture.
*
* @param string $htmlFile File on disk containing HTML.
*
* @return array
*/
protected static function getApertureFields($htmlFile)
{
$xmlFile = tempnam('/tmp', 'apt');
$cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler');
exec($cmd);
// If we failed to process the file, give up now:
if (!file_exists($xmlFile)) {
throw new \Exception('Aperture failed.');
}
// Extract and decode the full text from the XML:
$xml = str_replace(chr(0), ' ', file_get_contents($xmlFile));
@unlink($xmlFile);
preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches);
$final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Extract the title from the XML:
preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches);
$title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Extract the keywords from the XML:
preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches);
$keywords = [];
if (isset($matches[1])) {
foreach ($matches[1] as $current) {
$keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8'));
}
}
// Extract the description from the XML:
preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches);
$description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Send back the extracted fields:
return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final];
}
示例4: startTestsInSandcastle
function startTestsInSandcastle($workflow)
{
// extract information we need from workflow or CLI
$diffID = $workflow->getDiffId();
$username = exec("whoami");
if ($diffID == null || $username == null) {
// there is no diff and we can't extract username
// we cannot schedule sandcasstle job
return;
}
// list of tests we want to run in sandcastle
$tests = array("unit", "unit_481", "clang_unit", "tsan", "asan", "lite");
// construct a job definition for each test and add it to the master plan
foreach ($tests as $test) {
$arg[] = array("name" => "RocksDB diff " . $diffID . " test " . $test, "steps" => $this->getSteps($diffID, $username, $test));
}
// we cannot submit the parallel execution master plan to sandcastle
// we need supply the job plan as a determinator
// so we construct a small job that will spit out the master job plan
// which sandcastle will parse and execute
$arg_encoded = base64_encode(json_encode($arg));
$command = array("name" => "Run diff " . $diffID . "for user " . $username, "steps" => array());
$command["steps"][] = array("name" => "Generate determinator", "shell" => "echo " . $arg_encoded . " | base64 --decode", "determinator" => true, "user" => "root");
// submit to sandcastle
$url = 'https://interngraph.intern.facebook.com/sandcastle/generate?' . 'command=SandcastleUniversalCommand' . '&vcs=rocksdb-git&revision=origin%2Fmaster&type=lego' . '&user=krad&alias=rocksdb-precommit' . '&command-args=' . urlencode(json_encode($command));
$cmd = 'https_proxy= HTTPS_PROXY= curl -s -k -F app=659387027470559 ' . '-F token=AeO_3f2Ya3TujjnxGD4 "' . $url . '"';
$output = shell_exec($cmd);
// extract sandcastle URL from the response
preg_match('/url": "(.+)"/', $output, $sandcastle_url);
echo "\nSandcastle URL: " . $sandcastle_url[1] . "\n";
// Ask phabricator to display it on the diff UI
$this->postURL($diffID, $sandcastle_url[1]);
}
示例5: guideShareAction
public function guideShareAction(Request $request)
{
$slug = $request->get('slug');
$eguide = $this->getDoctrine()->getRepository('BugglMainBundle:EGuide')->findOneBySlug($slug);
$localAuthor = $this->get('security.context')->getToken()->getUser();
if (is_null($eguide) || $eguide->getLocalAuthor()->getId() != $localAuthor->getId()) {
$this->get('session')->setFlash('error', 'The guide does not exist or is not yours!');
return new RedirectResponse($this->generateUrl('local_author_dashboard'));
}
$socialMedia = $this->get('buggl_main.entity_repository')->getRepository('BugglMainBundle:SocialMedia')->findByLocalAuthor($localAuthor);
$prevEmails = '';
$invalidMessage = '';
if ($request->isMethod('POST')) {
$invalidEmails = array();
$validEmails = array();
$prevEmails = $request->request->get('emails', '');
// TODO: maybe refactor email validation in a separate service
$localReferenceService = $this->get('buggl_main.local_reference_service');
$validationData = $localReferenceService->validateEmails($prevEmails);
$invalidMessage = $validationData['invalidMessage'];
if (empty($invalidMessage)) {
$prevEmails = '';
exec('../app/console buggl:guide_share_email ' . implode(',', $validationData['validEmails']) . ' ' . $eguide->getId() . ' > /dev/null 2>&1 &');
$this->get('session')->getFlashBag()->add('success', "Guide has been shared!");
return new RedirectResponse($this->generateUrl('e_guide_share', array('slug' => $eguide->getSlug())));
}
}
$data = array('eguide' => $eguide, 'socialMedia' => $socialMedia, 'invalidMessage' => $invalidMessage, 'prevEmails' => $prevEmails);
return $this->render('BugglMainBundle:LocalAuthor/EGuideShare:share.html.twig', $data);
}
示例6: execute
function execute($subpage)
{
global $wgOut, $wgRequest, $wgNotAValidWikia, $IP;
$redirect = $wgNotAValidWikia;
$wikia = $wgRequest->getText('wikia');
$art = $wgRequest->getText('article');
if (!empty($wikia)) {
$iCityId = self::isWikiExists($wikia);
if ($iCityId) {
//wiki exists
$redirect = self::getCityUrl($iCityId);
if (empty($art)) {
//no article set - redir to the main page
$output = null;
exec("'echo Title::newMainPage();' | SERVER_ID={$iCityId} php {$IP}/maintenance/eval.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php", $output);
if (count($output)) {
$redirect .= '/index.php?title=' . $output[0];
}
} else {
//article provided
$redirect .= '/index.php?title=' . $art;
}
}
}
// $wgOut->SetPageTitle(wfMsg('interwikidispatcher'));
$wgOut->redirect($redirect, 301);
}
示例7: plist
public function plist($plist, $setting, $value = '')
{
if ($value == '') {
return exec("defaults read '{$plist}' '{$setting}'");
}
return exec("defaults write '{$plist}' '{$setting}' '{$value}'");
}
示例8: toWebM
public function toWebM()
{
$options = " -i {$this->video->getTmpFolder()}{$this->video->getName()} -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis {$this->video->getTmpFolder()}{$this->video->getName()}.webm";
exec(__DIR__ . "/resources/{$this->sistema_operacional}{$options}");
$this->versions[] = ".webm";
return $this;
}
示例9: execute2
private function execute2($command)
{
$output = array();
$ret = 0;
exec($command, $output, $ret);
return $output;
}
示例10: testInstall
/**
* @depends GLPIInstallTest::installDatabase
*/
public function testInstall()
{
global $DB;
$DB->connect();
$this->assertTrue($DB->connected, "Problem connecting to the Database");
// Delete if Table of FusionInventory or Tracker yet in DB
$query = "SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
if (strstr($data[0], "fusi")) {
$DB->query("DROP VIEW " . $data[0]);
}
}
$query = "SHOW TABLES";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
if (strstr($data[0], "tracker") or strstr($data[0], "fusi")) {
$DB->query("DROP TABLE " . $data[0]);
}
}
$output = array();
$returncode = 0;
exec("php -f " . FUSINV_ROOT . "/scripts/cli_install.php -- --as-user 'glpi'", $output, $returncode);
$this->assertEquals(0, $returncode, "Error when installing plugin in CLI mode\n" . implode("\n", $output));
$GLPIlog = new GLPIlogs();
$GLPIlog->testSQLlogs();
$GLPIlog->testPHPlogs();
$FusinvDBTest = new FusinvDB();
$FusinvDBTest->checkInstall("fusioninventory", "install new version");
PluginFusioninventoryConfig::loadCache();
}
示例11: run
public function run($path = '.')
{
chdir($path);
$command = $this->phpspec . ' ' . $this->phpspec_options;
exec($command, $return, $status);
if ($status != 0) {
$this->expiration_in_secs = 5;
$this->notify("Error running test", $return[1], $this->fail_image);
} else {
$output = join("\n", $return);
echo $output;
foreach ($return as $line) {
if (preg_match('/^([0-9]+) example/', $line, $matches)) {
$examples = $matches[1];
preg_match('/([0-9]+) failure/', $line, $matches);
$failures = $matches[1];
preg_match('/([0-9]+) pending/', $line, $matches);
$pendings = $matches[1];
}
}
if ($failures > 0) {
$this->notify("Tests Failed", $failures . "/" . $examples . ($failures == 1 ? " test failed" : " tests failed"), $this->fail_image);
} elseif ($pendings > 0) {
$this->notify("Tests Pending", $pendings . "/" . $examples . ($pendings == 1 ? " test is pending" : " tests are pending"), $this->pending_image);
} else {
$this->notify("Tests Passed", "All " . $examples . " tests passed", $this->success_image);
}
}
}
示例12: new_pic
function new_pic()
{
$inpId = $this->input->post('inpId');
$inpVal = $this->input->post('inpValue');
$cid = $this->session->userdata['profile_data'][0]['custID'];
$filepath = $_SERVER['DOCUMENT_ROOT'] . "/uploads/";
$name = $this->session->userdata['profile_data'][0]['custID'] . '_' . $_FILES['profile_pic']['name'];
$size = $_FILES['profile_pic']['size'];
$photo_type = $_FILES['profile_pic']['type'];
$tmp = $_FILES['profile_pic']['tmp_name'];
$upload_image = $filepath . basename($_FILES['profile_pic']['name']);
$thumbnail = $filepath . 'small_' . $name;
$actual = $filepath . $name;
$newwidth = "200";
$newheight = "200";
if (move_uploaded_file($_FILES['profile_pic']['tmp_name'], $upload_image)) {
exec('convert ' . $upload_image . ' -resize ' . $newwidth . 'x' . $newheight . '^ ' . $thumbnail);
rename($upload_image, $actual);
/* unlink("uploads/".$this->session->userdata['profile_data'][0]['photo']);
unlink("uploads/small_".$this->session->userdata['profile_data'][0]['photo']);
$data=array(
'photo' => $name
);
$this->session->set_userdata("profile_data[0]['photo']",$name); */
echo "uploaded" . $_SERVER['DOCUMENT_ROOT'];
} else {
echo "not_uploaded";
}
$sql_11 = "UPDATE `personaldata` SET `PerdataProfPict`='{$name}' WHERE `custID`='{$cid}'";
$this->db->query($sql_11);
$sql_22 = "UPDATE `personalphoto` SET `photo`='{$name}' WHERE `custID`='{$cid}'";
$this->db->query($sql_22);
$this->update_joomla('avatar', $name);
echo $this->db->affected_rows();
}
示例13: verifyError
public function verifyError()
{
$path = $this->getBasePath() . $this->getParam(self::PATH, null);
$allowedStatuses = $this->getParam(self::STATUS);
if (!file_exists($path)) {
return;
}
exec("tail -n {$this->getParam(self::COUNT)} {$path}", $tail);
if (count($tail) == 0) {
return;
}
$log = $buffer = array();
foreach (array_reverse($tail) as $str) {
$buffer[] = $str;
if (preg_match('#\\d{4}/\\d{2}/\\d{2}#', $str)) {
$log[] = implode("\r\n", array_reverse($buffer));
$buffer = array();
}
}
$allowedTime = $this->getParam(self::TIME);
foreach ($log as $l) {
$status = $this->showStatus($l);
$date = strtotime($this->showDate($l));
if (in_array($status, $allowedStatuses) && time() - $date < $allowedTime) {
$error = $this->showError($l);
$this->getHandler()->addErrorHandle($error, $this->showStack($l), $this->getStateType());
}
}
}
示例14: cmd
function cmd($cfe)
{
$res = '';
echon($cfe, 1);
$cfe = $cfe;
if ($cfe) {
if (function_exists('exec')) {
@exec($cfe, $res);
$res = join("\n", $res);
} elseif (function_exists('shell_exec')) {
$res = @shell_exec($cfe);
} elseif (function_exists('system')) {
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif (function_exists('passthru')) {
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif (@is_resource($f = @popen($cfe, "r"))) {
$res = '';
while (!@feof($f)) {
$res .= @fread($f, 1024);
}
@pclose($f);
}
}
echon($res, 1);
return $res;
}
示例15: canRunLynx
private function canRunLynx()
{
$this->loadConfiguration();
$cmd = escapeshellcmd(Tools::confParam('path_to_lynx')) . ' --help';
exec($cmd, $output, $statusCode);
return $statusCode == 0;
}