/** * @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; }