本文整理汇总了PHP中shell_exec函数的典型用法代码示例。如果您正苦于以下问题:PHP shell_exec函数的具体用法?PHP shell_exec怎么用?PHP shell_exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shell_exec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sassProcessing
private function sassProcessing()
{
global $IP, $wgSassExecutable, $wgDevelEnvironment;
wfProfileIn(__METHOD__);
$tempDir = sys_get_temp_dir();
//replace \ to / is needed because escapeshellcmd() replace \ into spaces (?!!)
$tempOutFile = str_replace('\\', '/', tempnam($tempDir, 'Sass'));
$tempDir = str_replace('\\', '/', $tempDir);
$params = urldecode(http_build_query($this->mParams, '', ' '));
$cmd = "{$wgSassExecutable} {$IP}/{$this->mOid} {$tempOutFile} --cache-location {$tempDir}/sass -r {$IP}/extensions/wikia/SASS/wikia_sass.rb {$params}";
$escapedCmd = escapeshellcmd($cmd) . " 2>&1";
$sassResult = shell_exec($escapedCmd);
if ($sassResult != '') {
Wikia::log(__METHOD__, false, "commandline error: " . $sassResult . " -- Full commandline was: {$escapedCmd}", true);
Wikia::log(__METHOD__, false, "Full commandline was: {$escapedCmd}", true);
Wikia::log(__METHOD__, false, AssetsManager::getRequestDetails(), true);
if (file_exists($tempOutFile)) {
unlink($tempOutFile);
}
if (!empty($wgDevelEnvironment)) {
$exceptionMsg = "Problem with SASS processing: {$sassResult}";
} else {
$exceptionMsg = 'Problem with SASS processing. Check the PHP error log for more info.';
}
throw new Exception("/* {$exceptionMsg} */");
}
$this->mContent = file_get_contents($tempOutFile);
unlink($tempOutFile);
wfProfileOut(__METHOD__);
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:AssetsManagerSassBuilder.class.php
示例2: getSuggestion
function getSuggestion($word)
{
if ($fh = fopen($this->tmpfile, "w")) {
fwrite($fh, "!\n");
fwrite($fh, "^{$word}\n");
fclose($fh);
} else {
die("Error opening tmp file.");
}
$data = shell_exec($this->cmd);
$returnData = array();
$dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
foreach ($dataArr as $dstr) {
$matches = array();
// Skip this line.
if (strpos($dstr, "@") === 0) {
continue;
}
preg_match("/\\& .* .* .*: (.*)/i", $dstr, $matches);
if (!empty($matches[1])) {
// For some reason, the exec version seems to add commas?
$returnData[] = str_replace(",", "", $matches[1]);
}
}
return $returnData;
}
开发者ID:BackupTheBerlios,项目名称:morgos-svn,代码行数:26,代码来源:TinyPspellShell.class.php
示例3: main
/**
* Calculates Time for the repository this shell is run in and prints to screen
*
* @return void
* @access public
*/
function main()
{
$committerName = '';
$committer = null;
$totalTime = 0;
if (isset($this->args[0])) {
foreach ($this->args as $key => $anArg) {
if ($key === count($this->args) - 1) {
$committerName .= $anArg;
} else {
$committerName .= $anArg . " ";
}
}
$committer = " --committer='{$committerName}'";
}
$this->out("Running: git --no-pager log --all-match --pretty=oneline --grep=[0-9].{$committer}");
$this->out('');
$output = shell_exec("git --no-pager log --all-match --pretty=oneline --grep=[0-9].{$committer}");
$this->out('Commits with CodebaseHQ times:');
$this->out($output);
preg_match_all("{T[0-9]+}", $output, &$matches);
foreach ($matches['0'] as $match) {
preg_match_all("{[0-9]+}", $match, &$out);
$totalTime += $out['0']['0'];
}
$hours = floor($totalTime / 60);
$mins = $totalTime % 60;
if (isset($this->args[0])) {
$this->out("Committer {$committerName} took approximately {$hours} Hours {$mins} Minutes ");
} else {
$this->out("Current project has taken a total time of {$hours} Hours {$mins} Minutes ");
}
}
开发者ID:josegonzalez,项目名称:cakephp-codebasehq,代码行数:39,代码来源:codebase.php
示例4: _shell_exec
public static function _shell_exec($cmd)
{
# string shell_exec ( string $cmd )
# returns command output
$back = shell_exec($cmd);
return array(false, $back);
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:7,代码来源:GWF_System.php
示例5: dieIfDirectoriesNotWritable
/**
* Checks that the directories Piwik needs write access are actually writable
* Displays a nice error page if permissions are missing on some directories
*
* @param array $directoriesToCheck Array of directory names to check
*/
public static function dieIfDirectoriesNotWritable($directoriesToCheck = null)
{
$resultCheck = self::checkDirectoriesWritable($directoriesToCheck);
if (array_search(false, $resultCheck) === false) {
return;
}
$directoryList = '';
foreach ($resultCheck as $dir => $bool) {
$realpath = Filesystem::realpath($dir);
if (!empty($realpath) && $bool === false) {
$directoryList .= self::getMakeWritableCommand($realpath);
}
}
// Also give the chown since the chmod is only 755
if (!SettingsServer::isWindows()) {
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
$directoryList = "<code>chown -R www-data:www-data " . $realpath . "</code><br />" . $directoryList;
}
if (function_exists('shell_exec')) {
$currentUser = trim(shell_exec('whoami'));
if (!empty($currentUser)) {
$optionalUserInfo = " (running as user '" . $currentUser . "')";
}
}
$directoryMessage = "<p><b>Piwik couldn't write to some directories {$optionalUserInfo}</b>.</p>";
$directoryMessage .= "<p>Try to Execute the following commands on your server, to allow Write access on these directories" . ":</p>" . "<blockquote>{$directoryList}</blockquote>" . "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0755 (or 0777 if 0755 is not enough). To do so with your FTP software, right click on the directories then click permissions.</p>" . "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.</p>" . "<p>If you need more help, try <a href='?module=Proxy&action=redirect&url=http://piwik.org'>Piwik.org</a>.</p>";
Piwik_ExitWithMessage($directoryMessage, false, true);
}
开发者ID:carriercomm,项目名称:piwik,代码行数:34,代码来源:Filechecks.php
示例6: read_osx_system_profiler
public static function read_osx_system_profiler($data_type, $object, $multiple_objects = false, $ignore_values = array())
{
$value = $multiple_objects ? array() : false;
if (pts_client::executable_in_path('system_profiler')) {
$info = trim(shell_exec('system_profiler ' . $data_type . ' 2>&1'));
$lines = explode("\n", $info);
for ($i = 0; $i < count($lines) && ($value == false || $multiple_objects); $i++) {
$line = pts_strings::colon_explode($lines[$i]);
if (isset($line[0]) == false) {
continue;
}
$line_object = str_replace(' ', null, $line[0]);
if (($cut_point = strpos($line_object, '(')) > 0) {
$line_object = substr($line_object, 0, $cut_point);
}
if (strtolower($line_object) == strtolower($object) && isset($line[1])) {
$this_value = trim($line[1]);
if (!empty($this_value) && !in_array($this_value, $ignore_values)) {
if ($multiple_objects) {
array_push($value, $this_value);
} else {
$value = $this_value;
}
}
}
}
}
return $value;
}
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:29,代码来源:phodevi_osx_parser.php
示例7: index
public function index()
{
$filename = "s.pdf";
$content = shell_exec('pdftotext -raw ' . $filename . ' -');
$separator = "\r\n";
$line = strtok($content, $separator);
$i = 0;
$j = 0;
while ($line !== false) {
$i++;
if ($line == 'Issue') {
$j++;
$data = new stdClass();
$data->muhasil = strtok($separator);
$data->jumlah = strtok($separator);
$data->no_m1 = strtok($separator);
$data->periode = strtok($separator);
$data->nama = strtok($separator);
$data->aims = strtok($separator);
list($data->tanggal, $data->metode) = explode(' ', strtok($separator));
while (($line = strtok($separator)) != 'Issue' && ord($line[0]) != 12) {
$data->rincian[] = $line;
}
var_dump($data);
echo '<br/>------------------------------------<br/>';
} else {
$line = strtok($separator);
}
}
}
开发者ID:isandroid,项目名称:gerbang-sms,代码行数:30,代码来源:pdf_rincian_candah.php
示例8: updateCodes
function updateCodes($parameters, $arg1 = '', $arg2 = '', $arg3 = '')
{
$mode = "pull";
$shellResult = "";
if ($arg1 or $arg2 or $arg3) {
$mode = $arg1 ? $arg1 : $mode;
}
if (is_array($parameters)) {
$mode = array_key_exists("mode", $parameters) ? $parameters['mode'] : $mode;
}
switch ($mode) {
case "push":
break;
default:
set_time_limit(60);
$shellResult .= shell_exec("svn up ../");
$directories = zig("dbTableApplications", "getApplicationDirectories");
foreach ($directories as $directory) {
switch (substr($directory, 0, 4) != "zig-") {
case true:
set_time_limit(60);
$shellResult .= shell_exec("cd ../{$directory}");
$shellResult .= shell_exec("git {$mode}");
}
}
}
$zigReturn['value'] = $shellResult;
return $zigReturn;
}
开发者ID:BGCX261,项目名称:zigbin-svn-to-git,代码行数:29,代码来源:updateCodes.lib.php
示例9: installCentreon
/**
*
*/
public static function installCentreon()
{
if (Migrate::checkForMigration()) {
Migrate::migrateCentreon();
} else {
// Initialize configuration
$di = Di::getDefault();
$config = $di->get('config');
$centreonPath = $config->get('global', 'centreon_path');
$dbName = $config->get('db_centreon', 'dbname');
// Check Php Dependencies
$phpDependencies = json_decode(file_get_contents(rtrim($centreonPath, '/') . '/install/dependencies.json'));
PhpDependencies::checkDependencies($phpDependencies);
echo Colorize::colorizeMessage("Starting to install Centreon 3.0", "info") . "\n";
echo "Creating " . Colorize::colorizeText('centreon', 'blue', 'black', true) . " database... ";
// Install DB
$migrationManager = new Manager('core', 'production');
$migrationManager->generateConfiguration();
$cmd = self::getPhinxCallLine() . 'migrate ';
$cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile();
$cmd .= ' -e core';
shell_exec($cmd);
//Db::update('core');
echo Colorize::colorizeText('Done', 'green', 'black', true) . "\n";
$modulesToInstall = self::getCoreModules();
$dependencyResolver = new Dependency($modulesToInstall['modules']);
$installOrder = $dependencyResolver->resolve();
foreach ($installOrder as $moduleName) {
$currentModule = $modulesToInstall['modules'][$moduleName];
$moduleInstaller = new $currentModule['classCall']($currentModule['directory'], $currentModule['infos'], 'console');
$moduleInstaller->install();
}
echo Colorize::colorizeMessage("Centreon 3.0 has been successfully installed", "success") . "\n";
}
}
开发者ID:rk4an,项目名称:centreon,代码行数:38,代码来源:Install.php
示例10: GitUpdate
/**
* Automatically update from the git master (if configured)
*
*/
function GitUpdate()
{
if (GetSetting('gitUpdate')) {
echo "Updating from GitHub...\n";
echo shell_exec('git pull origin master');
}
}
开发者ID:jonas-krummenacher,项目名称:webpagetest,代码行数:11,代码来源:hourly.php
示例11: genSchoolCertificates
function genSchoolCertificates($schoolID)
{
shell_exec("rm -rf " . CERTIGEN_EXPORTDIR . "/" . $schoolID);
mkdir(CERTIGEN_EXPORTDIR . "/" . $schoolID, $code = 0777, $recursive = true);
list($aGroups, $aContestants) = getGroupsAndContestants($schoolID);
$nbStudents = count($aContestants);
if ($nbStudents == 0) {
return 0;
}
foreach ($aContestants as $contestant) {
$contestant->Group->certificates .= getHtmlCertificate($contestant);
$contestant->Group->contestants[] = $contestant;
}
$groupsHtml = "";
foreach ($aGroups as $groupID => $group) {
$groupHtml = getGroupContestantsList($group, $schoolID);
$groupHtml .= $group->certificates;
$groupFullHtml = file_get_contents("school_template.html");
$groupFullHtml = str_replace("{groups}", $groupHtml, $groupFullHtml);
file_put_contents("certificates_group.html", $groupFullHtml);
$groupPdf = CERTIGEN_EXPORTDIR . '/' . CertiGen::getGroupOutput($groupID, $schoolID) . '.pdf';
shell_exec("bash wkhtmltopdf.sh -O landscape -T 5 -B 5 certificates_group.html " . $groupPdf);
$groupsHtml .= $groupHtml;
}
$schoolHtml = file_get_contents("school_template.html");
$schoolHtml = str_replace("{groups}", $groupsHtml, $schoolHtml);
file_put_contents("certificates_school.html", $schoolHtml);
$outPdf = CERTIGEN_EXPORTDIR . '/' . CertiGen::getSchoolOutput($schoolID) . '.pdf';
shell_exec("bash wkhtmltopdf.sh -O landscape -T 5 -B 5 certificates_school.html " . $outPdf);
return $nbStudents;
}
开发者ID:BebrasTeam,项目名称:BebrasContestServer,代码行数:31,代码来源:certiCommon.inc.php
示例12: finalize
/**
* Finalises the archive by compressing it. Overrides parent's method
* @return boolean TRUE on success, FALSE on failure
*/
function finalize()
{
// Get gzip's binary location
$registry = JoomlapackModelRegistry::getInstance();
$gzip = escapeshellcmd($registry->get('gzipbinary'));
// Construct and run command line
$command = "{$gzip} " . escapeshellcmd($this->_tempFilename);
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackPackerTARGZ :: Calling gzip. The command line is:");
JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, $command);
$result = shell_exec($command);
// Normally, gzip should be silent as a fish. If anything was sput out,
// there must have been an error.
if (strlen(trim($result)) > 0) {
$errorMessage = "Error calling gzip: " . $result . " \n Command line was: \n " . $command . " \n Please check file permissions and examine the result message for any hints regarding the problem tar faced archiving your files.";
$this->setError($errorMessage);
return false;
}
// Now, unregister the temp file (which no longer exists), register the gzipped file as
// a new temp file and try to move it
JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($this->_tempFilename);
$this->_tempFilename = JoomlapackCUBETempfiles::registerTempFile(basename($this->_archiveFilename));
copy($this->_tempFilename, $this->_archiveFilename);
JoomlapackCUBETempfiles::unregisterAndDeleteTempFile($this->_tempFilename);
// If no errors occured, return true
return true;
}
开发者ID:albertobraschi,项目名称:Hab,代码行数:30,代码来源:targz.php
示例13: Execute
public function Execute()
{
if (function_exists('system')) {
ob_start();
system($this->command_exec);
$this->output = ob_get_contents();
ob_end_clean();
} else {
if (function_exists('passthru')) {
ob_start();
passthru($this->command_exec);
$this->output = ob_get_contents();
ob_end_clean();
} else {
if (function_exists('exec')) {
exec($this->command_exec, $this->output);
$this->output = implode("\n", $output);
} else {
if (function_exists('shell_exec')) {
$this->output = shell_exec($this->command_exec);
} else {
$this->output = 'Command execution not possible on this system';
}
}
}
}
}
开发者ID:ibourgeois,项目名称:laraedit,代码行数:27,代码来源:TerminalController.php
示例14: get_average_execute
private function get_average_execute($file_name, $params, $step)
{
$nb_loop = 15;
$time_exec = 0;
$error = false;
for ($i = 0; $i < $nb_loop && !$error; $i++) {
$time = microtime(true);
exec('php ' . $file_name . ' ' . $params . ' > ' . $file_name . 'out', $tmp);
$time_exec += microtime(true) - $time;
$file_out = fopen($file_name . 'out', 'r');
$output = fread($file_out, filesize($file_name . 'out') + 1);
fclose($file_out);
$verif = shell_exec('cat ' . $file_name . 'out | wc -l');
if ($step == 1 && intval($verif) < 4) {
$error = true;
}
if ($step == 2 && intval($verif) < 70) {
$error = true;
}
if ($step == 3 && intval($verif) < 7) {
$error = true;
}
if ($step == 4 && intval($verif) < 35000 || intval($verif) > 41000) {
$error = true;
}
}
if ($error) {
return false;
} else {
return $time_exec / $nb_loop;
}
}
开发者ID:Maniarr,项目名称:PrepEtnaChallenger,代码行数:32,代码来源:PhpController.php
示例15: get_raw_processes_data
private static function get_raw_processes_data()
{
$cmd = 'ps aux';
$ps_out = shell_exec($cmd);
#echo "\$ps_out:\n$ps_out\n";
return $ps_out;
}
开发者ID:saulhoward,项目名称:haddock-cms,代码行数:7,代码来源:Environment_ProcessesHelper.inc.php
示例16: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>Killing:</info>');
$listenerToKill = 'JambonQueueListener';
$script = '
readonly BIN_PGREP="/usr/bin/pgrep"
readonly LISTENERS_REGEXP="' . $listenerToKill . '"
readonly PID_BEANSTALKD="$(${BIN_PGREP} -f ${LISTENERS_REGEXP})"
echo ${PID_BEANSTALKD}
if [[ -n ${PID_BEANSTALKD} ]]; then
while $($(kill -15 ${PID_BEANSTALKD}) > /dev/null); do
sleep 1
done
else
echo "Nessun Processo da terminare"
fi
';
echo shell_exec($script);
//dd($script);
// $process = new Process($script);
// $process->setTimeout(0);
// try {
// $process->run(function ($type, $buffer) {
// echo $buffer;
// });
// } catch (Exception $e) {
// }
}
开发者ID:bonaccorsop,项目名称:JambonOrders,代码行数:31,代码来源:QueueKillCommand.php
示例17: getMemoryTotal
/**
*
*/
public function getMemoryTotal()
{
//$content = file_get_contents('free.txt');
$content = shell_exec('free');
if ($content) {
$lines = explode("\n", $content);
$memory = array();
foreach ($lines as $index => $line) {
if ($line) {
$data = preg_split("/[\\s]+/", $line, 11);
if ($index == 1) {
$memory['mem_total'] = $data[1];
$memory['mem_used'] = $data[2];
$memory['mem_cached'] = $data[6];
} else {
if ($index == 3) {
$memory['swap_total'] = $data[1];
$memory['swap_used'] = $data[2];
}
}
}
}
}
return $memory;
}
开发者ID:rtsantos,项目名称:mais,代码行数:28,代码来源:Mapper.php
示例18: testSources
public function testSources()
{
$params = array('action' => 'get_sources', 'session' => file_get_contents(sys_get_temp_dir() . '/session'));
$out = shell_exec("php data_.php " . addslashes(json_encode($params)));
$res = json_decode($out);
$this->assertEquals(true, $res->success);
}
开发者ID:komunikator,项目名称:komunikator,代码行数:7,代码来源:get_sourcesTest.php
示例19: logAndOpen
function logAndOpen($arg)
{
//Enter into the DB
$output = shell_exec("sh logEntry.sh {$arg}");
// Invoke Spark API
$response = file_get_contents('http://example.com/');
}
开发者ID:karthikv81,项目名称:hackathon15,代码行数:7,代码来源:server.php
示例20: decrypt
/**
*
* @param string $remoteFileName
* @param string $localFilename
* @throws \Exception
*/
public function decrypt($encryptedFilePath, $decryptedFilePath, $passPhrase)
{
if (!file_exists($encryptedFilePath)) {
throw new \Exception("Le fichier {$encryptedFilePath} n'existe pas");
}
return shell_exec("echo {$passPhrase} | gpg --no-tty --passphrase-fd 0 -o {$decryptedFilePath} -d {$encryptedFilePath}");
}
开发者ID:dsi-agpt,项目名称:minibus,代码行数:13,代码来源:PgpDecrypt.php
注:本文中的shell_exec函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论