function _runCommand($command, $callback = null)
    {
        $this->log(1, "running: $command");
        $pp = popen("$command 2>&1", "r");
        if (!$pp) {
            return $this->raiseError("failed to run `$command'");
        }
        if ($callback && $callback[0]->debug == 1) {
            $olddbg = $callback[0]->debug;
            $callback[0]->debug = 2;
        }

        while ($line = fgets($pp, 1024)) {
            if ($callback) {
                call_user_func($callback, 'cmdoutput', $line);
            } else {
                $this->log(2, rtrim($line));
            }
        }
        if ($callback && isset($olddbg)) {
            $callback[0]->debug = $olddbg;
        }

        $exitcode = is_resource($pp) ? pclose($pp) : -1;
        return ($exitcode == 0);
    }
function _runCommand($command, $callback = null)
    {
        $this->log(1, "running: $command");
        $pp = popen("$command 2>&1", "r");
        if (!$pp) {
            return $this->raiseError("failed to run `$command'");
        }
        if ($callback && $callback[0]->debug == 1) {
            $olddbg = $callback[0]->debug;
            $callback[0]->debug = 2;
        }

        while ($line = fgets($pp, 1024)) {
            if ($callback) {
                call_user_func($callback, 'cmdoutput', $line);
            } else {
                $this->log(2, rtrim($line));
            }
        }
        if ($callback && isset($olddbg)) {
            $callback[0]->debug = $olddbg;
        }

        $exitcode = is_resource($pp) ? pclose($pp) : -1;
        return ($exitcode == 0);
    }
function _runCommand ( $ command , $ callback = null ) { $ this -> log ( 1 , "running: $command" ) ; $ pp = popen ( "$command 2>&1" , "r" ) ; if ( ! $ pp ) { return $ this -> raiseError ( "failed to run `$command'" ) ; } if ( $ callback && $ callback [ 0 ] -> debug == 1 ) { $ olddbg = $ callback [ 0 ] -> debug ; $ callback [ 0 ] -> debug = 2 ; } while ( $ line = fgets ( $ pp , 1024 ) ) { if ( $ callback ) { call_user_func ( $ callback , 'cmdoutput' , $ line ) ; } else { $ this -> log ( 2 , rtrim ( $ line ) ) ; } } if ( $ callback && isset ( $ olddbg ) ) { $ callback [ 0 ] -> debug = $ olddbg ; } $ exitcode = is_resource ( $ pp ) ? pclose ( $ pp ) : - 1 ; return ( $ exitcode == 0 ) ; }
Run an external command, using a message callback to report
output.  The command will be run through popen and output is
reported for every line with a "cmdoutput" message with the
line string, including newlines, as payload.

@param string $command the command to run

@param mixed $callback (optional) function to use as message
callback

@return bool whether the command was successful (exit code 0
means success, any other means failure)

@access private
Run an external command using a message callback to report output . The command will be run through popen and output is reported for every line with a cmdoutput message with the line string including newlines as payload .