I have a C++ console application that returns some kind of things, then, I need to show that in a browser. So I tried to write every console.write
from C++ to a .txt
file for future PHP reading, but no success because it doesn't write the errors!
Then I tried to use exec('program.exe', $output);
at PHP but no success too.. :/
.txt
every single thing that shows up in the console?There are three standard file handles known as stdin, stdout, stderr. Looks like you're only fetching stdout right now. Try to redirect stderr to stdout.
exec('program.exe 2>&1', $output);
(works not only on *nix but also win32).
see also: In the shell, what does " 2>&1 " mean?
You have to understand that cout (standard output) and cerr (standard error output) are two different streams, so probably you forgot to redirect cerr to your text file as well. Here some ideas you can use:
executable.exe > out.txt 2>&1
(see Redirect all output to file)