本文整理汇总了PHP中Process::getOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::getOutput方法的具体用法?PHP Process::getOutput怎么用?PHP Process::getOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::getOutput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detectProcessorNumberByGrep
protected function detectProcessorNumberByGrep()
{
if (Utils::findBin('grep') && file_exists('/proc/cpuinfo')) {
$process = new Process('grep -c ^processor /proc/cpuinfo 2>/dev/null');
$process->run();
$this->processorNumber = intval($process->getOutput());
return $this->processorNumber;
}
return;
}
示例2: wait
/**
* Blocks until call is complete.
*
* @throws \Exception If this function is called before start()
* @throws \RuntimeException
*
* @return string
*/
public function wait()
{
if ($this->processAsync == null) {
throw new \Exception('You must run `start` before running `wait`');
}
// blocks here until process completes
$this->processAsync->wait();
if (!$this->processAsync->isSuccessful()) {
throw new \RuntimeException($this->processAsync->getErrorOutput());
}
return $this->processAsync->getOutput();
}
示例3: executeCommand
/**
* Executes the given command via shell and returns the complete output as
* a string
*
* @param string $command
*
* @return array(status, stdout, stderr)
*/
protected function executeCommand($command)
{
if (class_exists('Symfony\\Component\\Process\\Process')) {
$process = new \Symfony\Component\Process\Process($command, $this->env);
if ($this->timeout !== false) {
$process->setTimeout($this->timeout);
}
} else {
$process = new Process($command, $this->env);
}
$process->run();
return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
}
示例4: print_update_step_output
/**
* Print update progress as dots for updating feature file step list.
*
* @param Process $process process executing update step command.
* @param string $featurestepfile feature step file in which steps will be saved.
* @return int exitcode.
*/
function print_update_step_output($process, $featurestepfile)
{
$printedlength = 0;
echo "Updating steps feature file for parallel behat runs" . PHP_EOL;
// Show progress while running command.
while ($process->isRunning()) {
usleep(10000);
$op = $process->getIncrementalOutput();
if (trim($op)) {
echo ".";
$printedlength++;
if ($printedlength > 70) {
$printedlength = 0;
echo PHP_EOL;
}
}
}
// If any error then exit.
$exitcode = $process->getExitCode();
// Output err.
if ($exitcode != 0) {
echo $process->getErrorOutput();
exit($exitcode);
}
// Extract features with step info and save it in file.
$featuresteps = $process->getOutput();
$featuresteps = explode(PHP_EOL, $featuresteps);
$realroot = realpath(__DIR__ . '/../../../../') . '/';
foreach ($featuresteps as $featurestep) {
if (trim($featurestep)) {
$step = explode("::", $featurestep);
$step[0] = str_replace($realroot, '', $step[0]);
$steps[$step[0]] = $step[1];
}
}
arsort($steps);
if (!@file_put_contents($featurestepfile, json_encode($steps, JSON_PRETTY_PRINT))) {
behat_error(BEHAT_EXITCODE_PERMISSIONS, 'File ' . $featurestepfile . ' can not be created');
$exitcode = -1;
}
echo PHP_EOL . "Updated step count in " . $featurestepfile . PHP_EOL;
return $exitcode;
}
示例5: executeCommand
/**
* Executes the given command via shell and returns the complete output as
* a string
*
* @param string $command
*
* @return array(status, stdout, stderr)
*/
protected function executeCommand($command)
{
$process = new Process($command, null, $this->env);
if (false !== $this->timeout) {
$process->setTimeout($this->timeout);
}
$process->run();
return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
}
示例6: executeCommand
/**
* Executes the given command via shell and returns the complete output as
* a string
*
* @param string $command
*
* @return array(status, stdout, stderr)
*/
protected function executeCommand($command)
{
if (class_exists('Symfony\\Component\\Process\\Process')) {
$process = new \Symfony\Component\Process\Process($command);
} else {
$process = new Process($command);
}
$process->run();
return array($process->getExitCode(), $process->getOutput(), $process->getErrorOutput());
}