从命令行:
sudo -u apache php -r 'exec("rsync -avi --rsh=\"ssh -o StrictHostKeyChecking=no -p22\" --omit-dir-times /var/www/html/ test@out:/var/www/html/ 2>&1", $a, $n);print_r($a);';
返回这个(我想要这样的输出):
Array
(
[0] => sending incremental file list
[1] => <f+++++++++ testrsync
[2] =>
[3] => sent 9143 bytes received 47 bytes 18380.00 bytes/sec
[4] => total size is 25642011 speedup is 2790.21
)
但从Apache2:
exec("rsync -avi --rsh=\"ssh -o StrictHostKeyChecking=no -p22\" --omit-dir-times /var/www/html/ test@out:/var/www/html/ 2>&1", $a, $n);
print_r($a);
我得到以下输出:
array (
0 => 'sending incremental file list',
1 => ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '',
312 => 'sent 139318 bytes received 183398 bytes 215144.00 bytes/sec',
313 => 'total size is 25642011 speedup is 79.46',
)
在测试之前,我删除了testrsync文件,并且从终端和浏览器rsync都成功传输了testrsync文件,但是在apache2中,它不显示以下行:
<f+++++++++ testrsync
我想通过浏览器中的Rsync获取已修改文件的列表。
Apache / 2.2.15,PHP 5.4.20,Centos 6.4
发现问题:
Rsync输出看起来像这样:
[1] => <f..t...... logo-1.png
[2] => <f..t...... logo.png
浏览器将<解析为新标签,因此我得到的输出为空,但源代码显示完整的输出。我花了一个多小时来调试它; D
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句