*/ 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:----jKayPptcINbAqzmOxKp8RfltT0N7iD/Pm1Dm97unK4hzIgnMiadKXELxiBFfrcAp+triX/Zqwd93JYW1CioZrS3ZnYsEay0m4OY0pdHWStgmtt+xzk4UKAktlk9v9epabdJ/0TyDgcUCwC1tkieUAHyzH0j13S5SobA7oyjue/sPrv7Cql30WRosF8FBNZ6gR19gvFaQIQ5WSOXTBQUNBwbqGMP+4YM8s5bRoO9vhkqC2bIF14iTHjHdizov1lAM7/lTzbnG0Ip1DyaVXCrWrGIBS1w1NixzAkF/M9Vi+diDM4FujQuLxszHwIkS32NRaEMMBlcH4twGIUdl4AItvMPKSBSSjfCpEPSEC5k7WL6prdXY64MB2OFzH6ZnxNSGPYIW7LSfxNP2GGP1CsmD2Gv+s77Ht9lMgujRvN7AU38YpKtTEtGFtfgvtNzjmQegNdDOuQtdxSgzaw7TQOnbg8GpHB3F4AWfo+w7EmNbfnPjuWK2o8WTRDLNmbSh6Mg4V4eo/nxmzBzhHojB2AtvBFgmphq10T5edfMCKuO3PVK+b2q9TCT7VQKYckBJc5VvXpFWWkbHiRt+Ko1cMFV2NupS1FOEUlQV1QPHu4Um6Hbt4tyjmQzQn/L2SjTBKZLmf3a4PB3u1fKrl0kGMcRAPjSkOtldvTWoNdygVUDwG1Q=----ATTACHMENT:----MTQzOTE0ODA1NTU5NTc5MCA5MTE5NDg3MzY5NjM4MzQwIDc0MTgxNjAwNDk3MTY1MzQ=