Esempio n. 1
0
 /**
  * Executes the wget command
  *
  * @return string
  */
 public function execute()
 {
     $command = $this->buildCommand();
     TimeTracker::start($command);
     $this->logger->debug('Executing WGet command ' . $command, __CLASS__);
     exec($command, $outputLines, $returnVar);
     $this->logger->debug('Called WGet command returned status ' . $returnVar, __CLASS__, array('time' => TimeTracker::stop($command)));
     return implode('\\n', $outputLines);
 }
 /**
  * Open a process with popen and process each line by logging and
  * collecting its output.
  *
  * @param string $command
  * @param string $logPrefix
  * @return array The exit code of the command and the returned output
  */
 protected function executeProcess($command, $logPrefix = '')
 {
     $returnedOutput = '';
     $fp = popen($this->prepareCommand($command), 'r');
     while (($line = fgets($fp)) !== false) {
         $this->logger->debug($logPrefix . rtrim($line), __CLASS__);
         $returnedOutput .= $line;
     }
     $exitCode = pclose($fp);
     return array($exitCode, $returnedOutput);
 }
 /**
  * @return string
  */
 protected function executeCommandLineOnShell()
 {
     $this->logger->debug(sprintf("Running command %s", $this->commandLine), __CLASS__);
     $this->shellCommandService->setRedirectStandardErrorToStandardOut(true);
     return $this->shellCommandService->execute($this->commandLine);
 }