The SystemExec Task
Basics
The SystemExec task is designed for embedding an executable :
- either directly by providing a staticaly compiled executable or
- using the CDE package, wich permit to build an archive packaging up your code and all its dependencies accessed during execution.
Creation
To create a SystemExec task:
> select Task > New > System exec in the top menu
> give it a name
> add a new resource (below the “commands” area) that will point the directory of your program (double-click in the text-field to get a file chooser).
> specify the workdir of your program from the resource(s) added.
> type the command for executing your program from the specified workdir. A workflow Prototype can be used in the commands by using the template ${name} (with name defined as Prototype).
Examples
Hello world
Let’s consider an executable that will print the classical “Hello world!” using a command line parameters. The executable is located in /home/user/Explo/hello/. As a usage example :
~/Explo/hello]$./hello OpenMOLE Hello from C! OpenMOLE
To configure a SystemExec Task for running this program :
> input the command line to run the executable in the Comand text area
> specify the path of the executable in the Resource field

This Task is runnable. A Prototype can also be used as input variable for the command line. For example, if the Task may receive a String variable named message as input, it can be used as follow (or be received from another previous Task in the workflow ) :

Hello world from a file
Let us now consider that the program reads its data from an input file. This input file will be set as input variable of the SystemExec Task, so that it can be generated by an other task previously in the Mole execution. If you do not need that, the file is constant and can be directly used from the resource previously added to the SystemExec Task.
Here is the source of our example program:
#include <stdio.h>
int main(int argc,char* argv[])
{
FILE *fp = fopen ( "input", "r" ) ;
char st[80];
fgets(st, 60, fp);
printf("Hello from C! %s\n",st);
return 0;
}
As you can see, this program will read the text file named “input” in the current directory. So the challenge for OpenMOLE is to place the file generated by a first task in the correct place in order to be found by the systemExec task. Here is how to achieve that easily:
> Create a Prototype of type File and give it a name (for example f)
> Create the Task that will generate this file, and add the Prototype as an output. Let us consider this demonstration example with a Groovy Task

> Now, you have to add an input mapping in your SystemExec Task in order to find the written file in your working directory. So, let’s map the Prototype of your file variable to the name of the file that your binary program is waiting for.

