2

I wrote a CAPL script that calls a python script using sysExecCmd like sysExecCmd("python",myParameters,myTree), where myTree is the current (nested) working tree wrt the current directory the CAPL resides in and myParameters are generated at runtime and take care of certain variables.

Problem is: every time sysExecCmd is called, it opens a new terminal and each one is persistent. I've tried to call a exit command without parameters in the same myTree like sysExecCmd("exit","",myTree), but it didn't work (and I didn't had many hopes it should have).

While the solution to the problem is not the central point here (I could do with a workaround and either use a batch or delegate to python to close the terminal somehow), I would like to know if there is a way to close terminals on the fly using CAPL scripts.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
  • I wouldn't want to go off topic but I have a doubt. How can you exchange data between the script you are running and the simulation that calls such script? – PySerial Killer Aug 01 '18 at 19:19

2 Answers2

3

Usually, for me it works in this way:

sysExecCmd("C:\\Projects\\CANoe\\some_script_to_execute && exit","");
BBart
  • 94
  • 4
2

&& exit does not always work.

You could also do this with the /c option.

/c Carries out the command specified by string and then stops.

Note that I am using sysExec and not sysExecCmd as the latter executes cmd with the /k option:

/k Carries out the command specified by string and continues.

snprintf(parameters, elcount(parameters), "/c mkdir %s", directoryName);
result = sysExec("cmd.exe", parameters, workingPath);
Erwin_H
  • 93
  • 8