我有这个简单的 php 脚本
<?php
echo '<pre>';
// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line = $output = system ("~/public_html/cgi-bin/srch.sh &> ~/public_html/errors.txt",$retval);
// Printing additional info
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
?>
依赖于 srch.sh:
#!/bin/bash
for i in ~/mail/home/user/mail/domain.com/josh/cur/*
do
grep -i Value $i . &> ~/public_html/yesno.txt;
done
但是,在 b 行器中显示的只是 Retval 1,并且没有错误记录到任何一个文本文件中。我是否错误地混合了标准错误和标准输出,或者错过了其他东西?