在我的服务器上,使用 popen 时,我无法将错误重定向到文本文件。以下代码:
popen("echo 'this part works' &> /wwwroot/output.txt &","r");
popen("noCommandThatExist &>> /wwwroot/output.txt &","r");
在我的机器上有以下输出:
this part works
sh: noCommandThatExist: command not found
但是服务器上的以下输出:
this part works
如果存在写权限问题,那么“这部分工作”将不会显示,我想知道这里发生了什么以及为什么错误没有重定向到 output.txt,因为它在我的本地服务器上。
在服务器(不是 Windows)上使用 Linux,因此重定向也应该在那里工作。