question

asb.p avatar image
0 Likes"
asb.p asked Joseph Gillespie commented

system command in Flexscript to run script on cmd line

Hello,

I want to run a script on the command line and get the output of the script back to flexsim. I want to run python script and get the suggestion of ML algorithm in to the simulation.

Example C++ code.

std::string filename = "/home/abc/xyz/Learning.py";
std::string command = "python ";
command += filename;
system(command.c_str());

I want to get the output of the script and use that in simulation.

Can anyone suggest the command like system which will be used to run the script on cmd line.

FlexSim 19.1.0
commands
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered Phil BoBo commented

The runprogram() command takes command line arguments, and passes them to the WinExec function. To get the output of the script, you will need some way to detect when your script is finished, since this command does not block.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

If you want to wait for a return value, then you could use a C++ DLL instead of FlexScript.

See How to let runprogram() wait for batch file (.bat) to finish

2 Likes 2 ·