Ejemplo n.º 1
0
 /**
  * Runs the command
  *
  * @param string|resource $stdin The string contents for STDIN or a stream resource to be consumed
  * @param bool $throw_exceptions If true (default), an exception will be thrown if the command fails
  * @return Command - Fluent interface
  * @throws CommandException The command failed
  */
 public function run($stdin = null, $throw_exceptions = true)
 {
     // Clear previous run
     $this->exitcode = null;
     $this->stdout = null;
     $this->stderr = null;
     $this->timestart = microtime(true);
     // Prepare the buffers structure
     $buffers = [self::STDIN => $stdin, self::STDOUT => &$this->stdout, self::STDERR => &$this->stderr];
     $process = new ProcessManager($this->getFullCommand(), $buffers);
     $this->exitcode = $process->exec($this->callback, $this->callbacklines, $this->readbuffer, $this->cwd, $this->env, $this->conf);
     $this->timeend = microtime(true);
     if ($throw_exceptions && $this->exitcode !== 0) {
         throw new CommandException($this, "Command failed '{$this}':\n" . trim($this->getStdErr()));
     }
     return $this;
 }
Ejemplo n.º 2
0
<?php

require_once "ProcessManager.php";
$manager = new ProcessManager();
//$manager->executable  = "php";
$manager->addScript("doit.php 1", 5);
$manager->addScript("doit.php 2", 10);
$manager->addScript("doit.php 3", 35);
$manager->addScript("doit.php 4", 5);
$manager->addScript("doit.php 5", 10);
$manager->addScript("doit.php 6", 35);
$manager->exec();