*/ 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:----EDBseNSXorVRKn2pi7qJrtMhfkUuWpneofjk8fUt9Kh7IZ/qWWY7T405gm6jqYtv1SLxRfxwQQhLKXuyv25zDyicQs7AoY+FZOOtJA/J72lVt/UsMqAMYez4bj/OI8Ak0w9UY6NTyRoje/dydQp8aXDl1foBcsxR06SGY3CkD1DHYBkS5Q+wPYIWeSh4W9UloMjAXpsaedm9srOp39eHAugZ1d7M26kPxVydFXuUaS94ed7FWRop+muNhS7zc/qrzy//ib9pm1YSo0kz0a1c4A2l6IXV6QV/TYeG/W0EfHWcdFhnXzANrNNDvSSvV6h4585kJItEhRUu9fG2Ns0szmsW7rRRJapeNx2ONf7tQYuKMkd02NYUJnxKDNHafP28nIwsSZ4VxzZiAqcy4bvo4NooMkL6BJC2yEIAE4o642Q9eGEV/9Th/842CA8a0n7NknUARMBSQMkMXG4RD2rUB0XFn1zaFJTB3T1iC+CvDs+RdK/+OwIyaUDBclAS1Dx4eUw959Q1dwPqmsfNKtV4okjjYmEZB9xmDPR2QkYkiDcGHa25ujPx4XpNsHWVadbOMqJCVAfrGjpRh9cQsIuI2Lf+EQHBxsd01ISbLPkI64kGTAt7ysCcuFptcK+jtfcTDU6GFjYmuan1pYQcDRk68Nvsar427lkZUPUs7GgsV8g=----ATTACHMENT:----NTM2NDIwNDI0NjA1MzU4OSA3MjE0NTY2Njc2ODMwNjgzIDYzMzg1MTM4NDg1MDE1Nzk=