0

I try to execute following "unknown.exe" command in CVI platform (as C code batch script) and redirect those command output in a log file.

sprintf(szCommand, "%s > D:\\log.txt 2>&1", "D:\\unknown.exe");
system(szCommand);

When I run the script, the exe file can execute but its failed to obtain the output "log file".

I don't understand what went wrong here.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Math2101
  • 11
  • 2
  • I suggest to print the value of `szCommand` before calling `system` and the return value of `system`. Please add this and the corresponding output to your question. What exactly means "failed to obtain the output log file"? Does the file exist before/after running the program? Is it empty? Does it contain unexpected output? How do you know that the program gets executed? – Bodo Apr 03 '20 at 12:37
  • @Bodo thanks for reply, i print the szcommand --> D:\\LensCalib.exe > D:\\log.txt 2>&1 and the return values of the system is 0 (which meant the exe file run succesfully but the output log file is "not found" in the Directory --> D:\\log.txt).. the same command when i tried at (.cmd)command win prompt.. its work perfect there i can see the log.txt in the directory. but in the script platform log.txt file is not found.. Does anythink is wrong at my script ? – Math2101 Apr 03 '20 at 13:44
  • Please [edit] your questuion and add all information to the question. Please copy&paste the complete code including the output of `szSystem` and the result. Do you really get `D:\\LensCalib.exe > D:\\log.txt 2>&1` with double backslashes? – Bodo Apr 06 '20 at 09:41

0 Answers0