Table of Contents
RUN PROGRAM
Category: Workflow / External
Description
This action runs a specified external application and waits until it finishes.
If no external application is provided the command line is executed by the Windows shell (cmd.exe).
The action fails if the extеrnal application returns a non-zero exit code.
Use cases
- Run external applications (e.g. after a file is generated by EasyMorph).
- Execute Windows shell commands (copy, del, ren, etc.).
- Run other EasyMorph projects in order to make them generate reports.
Action settings
Setting | Description |
---|---|
Application* | Enter or browse to the fully qualified path and filename of the program's executable file. If this is left blank, the command line is executed by the Windows shell (cmd.exe). |
Working directory (optional)* | Enter the folder containing any files required by the application. |
Arguments | Enter the values, filenames, commands, etc. passed to the application as either static text or a calculated string. Options: Text or Calculated. See the table below for details. |
Halt if exit code is not 0 | When this is checked, the workflow will stop and display an error if the run program terminates with an error. |
Capture output | When checked, EasyMorph will capture any returned data in a dataset (e.g., to see errors). See the "Capturing output" section below under "Remarks" for more information. |
* Setting can be specified using a parameter.
Argument options
Option | Description |
---|---|
Text | Enter static text arguments. |
Calculated | Enter an expression to calculate the argument string. |
Incorporating parameters is supported in both options (e.g., {MyParam}). See the "Parameter substitution" section below under "Remarks" for more information about using parameters in arguments.
Remarks
Parameter substitution
The action allows defining its command line as static text or as a calculated expression. It is possible to insert parameters into text. For instance:
copy /Y {SourceFileName} {DestinationFileName}
The command line above is equivalent to the calculated expression below but is easier to use.
“copy /Y “ & {SourceFileName} & “ “ & {DestinationFileName}
SourceFileName and DestinationFileName are parameter names.
Capturing output
It is possible to capture STDOUT and STDERR of the executed external application or Windows shell command. For instance, it is possible to run dir and capture its output as a table in EasyMorph, or forward the output of an application into EasyMorph without creating a temporary intermediate CSV file.
STDERR is captured in a separate column, which can later be used for error-handling routines. Since EasyMorph also outputs errors into STDERR this feature can be used for error handling of EasyMorph projects executed in the command line mode.
Examples
Example 1: Running the external 7-Zip program to unzip a file or files.
Action parameters:
Application "C:\Program Files (x86)\7-Zip\7z.exe" (the full path and name of program executable)
Working directory is "C:\Zipped files" (the folder the application will find the file(s) to be unzipped)
Calculated argument' e "' & {File name} & '" -y -aoa'
(the argument string required by 7-Zip to decompress the file(s); note {File name} is an EasyMorph parameter)
Halt if exit code is not 0 is checked (the workflow will stop with an error if 7-Zip does not complete correctly)
Example 2: Run the Windows shell command to copy a file.
Action parameters:
Application is left blank (the Windows shell will run the command below)
Calculated argument is the shell command:'copy /Y "' & {Old location} & '" "' & {New location} & '"'
(note {Old location} and {New location} are EasyMorph parameters)
Hard if exit code is not 0 is checked (the workflow will stop with an error if the copy command does not complete successfully)
Community examples
- How to obtain a list of all files recursively (Project; Module: Main; Group: Tab 1; Table: Table 1; Action position: 1)
- EasyMorph 4.3 : Tableau Hyper Addon logs (Project; Module: Main; Group: Tab 1; Table: Convert DSET file to Hyper file;
Action position: 4) - Extracting all projects published in the Community and their actions (Project; Module: Main loop; Group: Group 1; Table: Actions; Action position: 6)