Description and usage of ExecuteProcess:

Runs an operating system command specified by the user and writes the output of that command to a FlowFile. If the command is expected to be long-running, the Processor can output the partial data on a specified interval. When this option is used, the output is expected to be in textual format, as it typically does not make sense to split binary data on arbitrary time-based intervals.

Tags:

command, process, source, external, invoke, script

Properties:

In the list below, the names of required properties appear inĀ bold. Any other properties (not in bold) are considered optional. The table also indicates any default values.

Name Default Value Allowable Values Description
Command Specifies the command to be executed; if just the name of an executable is provided, it must be in the user's environment PATH.
Command Arguments The arguments to supply to the executable delimited by white space. White space can be escaped by enclosing it in double-quotes.
Batch Duration If the process is expected to be long-running and produce textual output, a batch duration can be specified so that the output will be captured for this amount of time and a FlowFile will then be sent out with the results and a new FlowFile will be started, rather than waiting for the process to finish before sending out the results
Redirect Error Stream false * true</br> * false If true will redirect any error stream output of the process to the output stream. This is particularly helpful for processes which write extensively to the error stream or for troubleshooting.
Argument Delimiter Delimiter to use to separate arguments for a command [default: space]. Must be a single character.

Dynamic Properties:

Dynamic Properties allow the user to specify both the name and value of a property.

Name Value Description
An environment variable name An environment variable value These environment variables are passed to the process spawned by this Processor

Relationships:

Name Description
success All created FlowFiles are routed to this relationship

Reads Attributes:

None specified.

Writes Attributes:

None specified.

How to Configure?

This sample explains how to perform the addition of two numbers by passing the input as command-line arguments using the ExecuteProcess processor.

C# code for addition:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace addition
{
  class Program
  {
    static void Main(string[] args)
    {
        int sum = 0;
        int x = 0;
        int y = 0;
        x = Convert.ToInt32(args[0]);
        y = Convert.ToInt32(args[1]);
        sum = x + y;
        Console.WriteLine("Sum of " + x + " and " + y + " is " + sum);
    }
  }
}

Create a workflow in the Data Integration Platform:

Overview:

sample

Step 1: Execute the .exe file

Drag and drop the ExecuteProcess processor to execute the .exe file and specify the following properties.

Command: <Your exe filepath>

Command Arguments: <input to be passed as arguments>

Argument Delimiter: Default value is <space>

sample

Step 2: Store the response in a file

Drag and drop the PutFile processor and specify the file location as below to store the incoming flow file content (output of addition of two numbers).

sample

Output:

After starting the processors, the result will be stored in the specified location as follows.

sample