[Moved] system() not running as expected
I am using the system() function to run a system command. While using the system(), the command I am using is:
However, the output of this is not being correctly sent to the txt file. To be more specific, the txt file is created, however the output is not appended to the file.
On running the same command from the CMD, the output is correctly sent to the txt file.
Any idea on what's going wrong?
Moved to C++ Gurus forum as it's completely unrelated to Qt (system is a standard C library function).
Try launching your command line app as arguments passed to cmd.exe. I seem to remember having to do this in the past (a long time ago).
In general calling system is a bad practice. In your case the problem is related to the command that you are executing not to the source code.
To solve your issue you might have to log both STDOUT and STDERR to the file. For more info check: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
"QProcess":http://doc.qt.nokia.com/4.7/qprocess.html should be a good alternative. You have control over stdin and stdout there.