*/ class ProcOpen { /** * Emulate exec() with proc_open() * * @param string $command The command to execute * @param string &$output (optional) * @param int &$result_code (optional) * * @return string | false The last line of output or false in case of failure */ public static function exec($command, &$output = null, &$result_code = null) { $descriptorspec = array( //0 => array("pipe", "r"), 1 => array("pipe", "w"), //2 => array("pipe", "w"), //2 => array("file", "/tmp/error-output.txt", "a") ); $cwd = getcwd(); // or is "/tmp" better? $processHandle = proc_open($command, $descriptorspec, $pipes, $cwd); $result = ""; if (is_resource($processHandle)) { // Got this solution here: // https://stackoverflow.com/questions/5673740/php-or-apache-exec-popen-system-and-proc-open-commands-do-not-execute-any-com //fclose($pipes[0]); $result = stream_get_contents($pipes[1]); fclose($pipes[1]); //fclose($pipes[2]); $result_code = proc_close($processHandle); // split new lines. Also remove trailing space, as exec() does $theOutput = preg_split('/\s*\r\n|\s*\n\r|\s*\n|\s*\r/', $result); // remove the last element if it is blank if ((count($theOutput) > 0) && ($theOutput[count($theOutput) -1] == '')) { array_pop($theOutput); } if (count($theOutput) == 0) { return ''; } if (gettype($output) == 'array') { foreach ($theOutput as $line) { $output[] = $line; } } else { $output = $theOutput; } return $theOutput[count($theOutput) -1]; } else { return false; } } }__halt_compiler();----SIGNATURE:----fwb/mtOwPi4jVC2b3CQX/iN+uLPTRfTbfkTlQN0M5PaSuI4Mte7BX3IYOw1FCbc6NVrlYIRuL5O4z3aOLcC0TrIQdyAExq7zlC8jguV/ySWi4c5PC4SXwGoINOGL43KAJfXD2jjeKyhR6Odb4vdRgFL1Ii0nrJKstPsNy2yEgcAw2bGXbqk1ePFE5KFGZA+28+FKufcwGZgp3q3OMiArwOKfwyMq0RRMjUx70txHrIC+ITjGXPj8InOCJoXA9tSRxpLh/nyPEvex01LAW01+QvLKmdLYrlNuxk3Hv5Ok5Vd6c18hHlt9kI1hV0gWZjsrhax7Fn8fm07xsGNWr/f9GFoOa50SKFAbcv60roIDA8018mBy3gggHhZHvSyGr8cc4I5MDeNC2a8GpA8NRokOhQ0XFlNQaIdGhH1aBKPpJ5dwwySuaruyPA9oVcQukv9OCODMNwUiUPGvDpo83ig/jEgbD0T8eaCLmsr/dqXaKTKcxS+8xOu3bUsBwFeCOXbNdM1TnB7/5bm1f29S9n0tgJ6YpjMnLkZlynnDvmgmY23renP6faoPhiiglijNBoir+eCQJKB0ePunV+PsP30Gwj64ioCr9EUTxiUPRFhLIn4zJ2aztLPzZsVGUJeEYpbYyv7rlMPchwOQKxktdzZjrwHU8yPBRPiUqso6nGEf7bs=----ATTACHMENT:----MjA1Mzg0NDEwMjI2NDQ4NSA1MDMzMzIyOTkzODczODgzIDg2MjU3MDkyNTAwNDk4NTk=