0

From C++ source, I execute the following line:

system("../BWAPI/ITUBot/Clingo/clingo.exe bwapi-data/AI/ITUBotWall.txt > bwapi-data/AI/solver-out.txt");

This line causes an empty solver-out.txt to be created. If I execute the same command using command line from outside the C++ program, the output file is successfully created with relevant contents.

The ITUBotWall.txt is created just before this command. Would this be relevant to the issue?

What would the reason be behind this? What am I missing and how can I solve this?

Varaquilex
  • 3,447
  • 7
  • 40
  • 60

2 Answers2

2

Try this -:
system("../BWAPI/ITUBot/Clingo/clingo.exe < bwapi-data/AI/ITUBotWall.txt > bwapi-data/AI/solver-out.txt");

Anmol Singh Jaggi
  • 8,376
  • 4
  • 36
  • 77
  • No difference. Still empty file. – Varaquilex May 13 '14 at 16:49
  • Are you sure you are entering the paths of the files correctly ? Try entering full absolute paths. Instead of `bwapi-data/AI/ITUBotWall.txt` , try `:/.../bwapi-data/AI/ITUBotWall.txt`. Same for output file and executable file. – Anmol Singh Jaggi May 13 '14 at 16:54
  • I'm sure because the solver-out.txt is generated by this line. – Varaquilex May 13 '14 at 16:55
  • Write `perror("")` just after the `system()` line in your code. Do you get any error message? – Anmol Singh Jaggi May 13 '14 at 16:59
  • I am not using `stdout`, I am debugging using in-game text. So I printed `_doserrno` before and after the system call. The output is Before :3, After :0. Seems like there's no error after calling the external program. – Varaquilex May 13 '14 at 17:32
1

You should make all paths absolute.

ilkerulusoy
  • 102
  • 2
  • 9