On my server I am unable to redirect errors to a text file when using popen. The following code:
popen("echo 'this part works' &> /wwwroot/output.txt &","r");
popen("noCommandThatExist &>> /wwwroot/output.txt &","r");
Has the following output on my machine:
this part works
sh: noCommandThatExist: command not found
But the following output on the server:
this part works
If there was a write permission problem then “this part works” would not show, I wonder what’s going on here and why the error is not redirected to output.txt as it is on my local server.
Using Linux on the server (not Windows) so redirecting should work there as well.
Sorry, just found out that if I delete the first line I actually get the error.
Maybe somehow the first command completes later than the second one and overwrites it or it’s something else but I can live with only the one command so will work with that.