Full path: /system/shell/commandline
Executes a shell command or a batch file.
To have FlowForce Server jobs read environment variables, they must be defined in scripts, and those scripts must be executed with the /system/shell/commandline function. Be aware that FlowForce Server is running a non-interactive shell, which means all behavior specific to interactive shells is not applicable (such as executing .profile or .bashrc on Linux).
If the exit code from the last shell command is other than "0", the outcome is as follows:
•If the parameter Abort on error is true (default), this function aborts execution. In this case, you can handle the error by means of protected blocks (see Handling Step Errors).
•If the parameter Abort on error is false, the function returns the result of the shell command, including the standard output, the standard error, and the exit code.
If the exit code from the last command is "0" (success), the function returns the result of the last shell command, as generic type. To handle the value returned by this function in another step or job, do the following:
1. Name the returned result by entering a value in the Assign this step’s result to text box (for example, "myresult").
2. Create a new step which executes either the function compute or compute-string, depending on what return type you need.
3. Enter as argument to the above function an expression which gets the desired part from the generic result. For example, enter the expression stdout(myresult) to get the standard output of the result as stream, and stderr(myresult) to get the standard error output stream. To get the same values as string, use content(stdout(myresult)) and content(stderr(myresult)), respectively.
Note that the stdout function (and the job) will fail if the shell command does not return a standard output. Likewise, the stderr function will fail if there is no standard error.
Enter the shell command to execute.
Abort on error
Optional parameter. This parameter determines the outcome of a job in which an error has occurred. If the Abort on error parameter is true, job execution will be terminated. If the Abort on error parameter is false, FlowForce Server will ignore errors and continue job execution. The default value is true.
string as directory
Specifies the working directory of the job (for example, c:\somedirectory). If relative paths are used, they will be resolved against the working directory.
The following job executes a Windows batch file called DoTransform.bat. Assuming that the DoTransform.bat requires some XML file as input, the input XML file must be copied to the working directory. In this example, the working directory is C:\codegen\xslt2.
The following job calls RaptorXML Server to run an XSLT transformation with parameters. It is assumed that the PATH environment variable contains the path to the RaptorXML Server executable, for example C:\Program Files (x86)\Altova\RaptorXMLServer2023\bin. For more information about RaptorXML Server, see https://www.altova.com/raptorxml.
For a step-by-step example which handles the output returned by the command line, see Check if a path exists.