Exemple #1
0
 /**
  * @param string $command nur der befehl oder mehrere (z. B. lb für list simple)
  * @param array $options alle optionen ohne - davor
  */
 protected function exec($command, array $options = array(), $append = NULL)
 {
     $cmd = sprintf('%s %s%s %s%s', SystemUtil::escapeShellArg($this->bin), $command, count($options) > 0 ? \Webforge\Common\ArrayUtil::join($options, ' -%s') : NULL, (string) escapeshellarg($this->rar), mb_strlen($append) > 0 ? ' ' . $append : NULL);
     $out = array();
     $ret = NULL;
     $out = System::execute($cmd, NULL, NULL, $stdout, $stderr, NULL, $ret);
     if ($ret !== 0) {
         throw new Exception(sprintf("Fehler '%s' beim Ausführen des Befehls '%s'. Rückgabe: %d", $out, $cmd, $ret));
     }
     /* sonderfall für listfiles denn das gibt immer $ret = 0 zurück, toll, was? */
     if (!empty($stderr)) {
         throw new Exception(sprintf("Fehler '%s' beim Ausführen des Befehls '%s'.", $stderr, $cmd));
     }
     return $out;
 }
Exemple #2
0
 /**
  * @return bool
  * @throws Exception bei Parse Errors
  */
 public function syntaxCheck(File $file, $do = 'throw')
 {
     if (!$file->exists()) {
         throw new \RuntimeException('Datei ' . $file . ' existiert nicht. Syntax check nicht möglich');
     }
     $process = new \Psc\System\Console\Process(System::which('php') . ' -l -f ' . escapeshellarg((string) $file));
     $exit = $process->run();
     if ($exit > 0 || $exit == -1) {
         if ($do === 'throw') {
             throw new SyntaxErrorException($process->getOutput());
         } else {
             return FALSE;
         }
     } else {
         return TRUE;
     }
 }
Exemple #3
0
 public static function executeBackground($cmd, $flags = 0x0)
 {
     $win = $flags ^ self::FORCE_UNIX && PSC::getEnvironment()->getOS() == Environment::WINDOWS;
     if (!$win) {
         throw new \Psc\Exception('Unix Implementation nicht da ');
     } else {
         $cmd = System::which('start') . ' /B ' . $cmd . ' ';
         return pclose(popen($cmd, 'r'));
     }
 }
Exemple #4
0
 public function testWhichNoException()
 {
     $this->assertEquals($this->notAvaibleCmd, System::which($this->notAvaibleCmd));
 }