1. 程式人生 > >php+lunix的exec錯誤提示不能捕獲解決

php+lunix的exec錯誤提示不能捕獲解決

<?php
$cmd = '/home/xiaoyan/svn.sh2>&1';
$str = exec($cmd, $out, $re);
echo '<pre>';
print_r(array('cmd' => $cmd, 'exec_return' => $str, 'exec_out' => $out, 'exe_re' => $re));
echo '</pre>';

----進行錯誤輸出重定向[ 2>&1]的輸出,如果不重定向,無權提示是無法捕獲的----

Array( [cmd] => /home/xiaoyan/svn.sh 2>&1 [exec_return] => svn: Can't open file '/var/www/phpcms/statics/images/chrd/.svn/lock': Permission denied [exec_out] => Array ( [0] => svn: Can't open file '/var/www/phpcms/statics/images/chrd/.svn/lock': Permission denied ) [exe_re] => 1)