public function executeCommand($args = array())
    {
        $this->lastOutput = array();

        $command = call_user_func_array('sprintf', $args);
        $this->logger->logDebug($command);

        if ($this->quiet) {
            $this->logger->log('Executing: ' . $command);
        }

        $status = 0;
        $descriptorSpec = array(
            0 => array("pipe", "r"),  // stdin
            1 => array("pipe", "w"),  // stdout
            2 => array("pipe", "w"),  // stderr
        );

        $pipes = array();
        $process = proc_open($command, $descriptorSpec, $pipes, $this->buildPath, null);

        if (is_resource($process)) {
            fclose($pipes[0]);

            stream_set_blocking($pipes[1], 0);
            stream_set_blocking($pipes[2], 0);

            $lastOutput = '';
            $lastError  = '';
            do {
                usleep(200); //Give It Time To Start

                while (($newData = fread($pipes[1], 1024)) && !feof($pipes[1])) {
                    $lastOutput .= $newData;
                }

                while (($newData = fread($pipes[2], 1024)) && !feof($pipes[2])) {
                    $lastError .= $newData;
                }

                $processStatus = proc_get_status($process);
            } while ($processStatus['running']);

            $this->lastOutput = $lastOutput;
            $this->lastError  = $lastError;

            fclose($pipes[1]);
            fclose($pipes[2]);

            proc_close($process);
            $status = $processStatus['exitcode'];
        }

        $this->lastOutput = array_filter(explode(PHP_EOL, $this->lastOutput));

        $shouldOutput = ($this->logExecOutput && ($this->verbose || $status != 0));

        if ($shouldOutput && !empty($this->lastOutput)) {
            $this->logger->log($this->lastOutput);
        }

        if (!empty($this->lastError)) {
            $this->logger->log("\033[0;31m" . $this->lastError . "\033[0m", LogLevel::ERROR);
        }

        $rtn = false;

        if ($status == 0) {
            $rtn = true;
        }

        return $rtn;
    }
public function executeCommand($args = array())
    {
        $this->lastOutput = array();

        $command = call_user_func_array('sprintf', $args);
        $this->logger->logDebug($command);

        if ($this->quiet) {
            $this->logger->log('Executing: ' . $command);
        }

        $status = 0;
        $descriptorSpec = array(
            0 => array("pipe", "r"),  // stdin
            1 => array("pipe", "w"),  // stdout
            2 => array("pipe", "w"),  // stderr
        );

        $pipes = array();
        $process = proc_open($command, $descriptorSpec, $pipes, $this->buildPath, null);

        if (is_resource($process)) {
            fclose($pipes[0]);

            stream_set_blocking($pipes[1], 0);
            stream_set_blocking($pipes[2], 0);

            $lastOutput = '';
            $lastError  = '';
            do {
                usleep(200); //Give It Time To Start

                while (($newData = fread($pipes[1], 1024)) && !feof($pipes[1])) {
                    $lastOutput .= $newData;
                }

                while (($newData = fread($pipes[2], 1024)) && !feof($pipes[2])) {
                    $lastError .= $newData;
                }

                $processStatus = proc_get_status($process);
            } while ($processStatus['running']);

            $this->lastOutput = $lastOutput;
            $this->lastError  = $lastError;

            fclose($pipes[1]);
            fclose($pipes[2]);

            proc_close($process);
            $status = $processStatus['exitcode'];
        }

        $this->lastOutput = array_filter(explode(PHP_EOL, $this->lastOutput));

        $shouldOutput = ($this->logExecOutput && ($this->verbose || $status != 0));

        if ($shouldOutput && !empty($this->lastOutput)) {
            $this->logger->log($this->lastOutput);
        }

        if (!empty($this->lastError)) {
            $this->logger->log("\033[0;31m" . $this->lastError . "\033[0m", LogLevel::ERROR);
        }

        $rtn = false;

        if ($status == 0) {
            $rtn = true;
        }

        return $rtn;
    }
public function executeCommand ( $ args = array ( ) ) { $ this -> lastOutput = array ( ) ; $ command = call_user_func_array ( 'sprintf' , $ args ) ; $ this -> logger -> logDebug ( $ command ) ; if ( $ this -> quiet ) { $ this -> logger -> log ( 'Executing: ' . $ command ) ; } $ status = 0 ; $ descriptorSpec = array ( 0 => array ( "pipe" , "r" ) , // stdin 1 => array ( "pipe" , "w" ) , // stdout 2 => array ( "pipe" , "w" ) , // stderr ) ; $ pipes = array ( ) ; $ process = proc_open ( $ command , $ descriptorSpec , $ pipes , $ this -> buildPath , null ) ; if ( is_resource ( $ process ) ) { fclose ( $ pipes [ 0 ] ) ; stream_set_blocking ( $ pipes [ 1 ] , 0 ) ; stream_set_blocking ( $ pipes [ 2 ] , 0 ) ; $ lastOutput = '' ; $ lastError = '' ; do { usleep ( 200 ) ; //Give It Time To Start while ( ( $ newData = fread ( $ pipes [ 1 ] , 1024 ) ) && ! feof ( $ pipes [ 1 ] ) ) { $ lastOutput .= $ newData ; } while ( ( $ newData = fread ( $ pipes [ 2 ] , 1024 ) ) && ! feof ( $ pipes [ 2 ] ) ) { $ lastError .= $ newData ; } $ processStatus = proc_get_status ( $ process ) ; } while ( $ processStatus [ 'running' ] ) ; $ this -> lastOutput = $ lastOutput ; $ this -> lastError = $ lastError ; fclose ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 2 ] ) ; proc_close ( $ process ) ; $ status = $ processStatus [ 'exitcode' ] ; } $ this -> lastOutput = array_filter ( explode ( PHP_EOL , $ this -> lastOutput ) ) ; $ shouldOutput = ( $ this -> logExecOutput && ( $ this -> verbose || $ status != 0 ) ) ; if ( $ shouldOutput && ! empty ( $ this -> lastOutput ) ) { $ this -> logger -> log ( $ this -> lastOutput ) ; } if ( ! empty ( $ this -> lastError ) ) { $ this -> logger -> log ( "\033[0;31m" . $ this -> lastError . "\033[0m" , LogLevel :: ERROR ) ; } $ rtn = false ; if ( $ status == 0 ) { $ rtn = true ; } return $ rtn ; }
Executes shell commands.
@param array $args
@return bool Indicates success
Executes shell commands .