user6790479
user6790479

Reputation: 33

Nifi executeprocess processor

I am using executeprocess processor to execute shell script. But I want to make sure that if script executed successfully then only flow should go to next processor. Is there any way to check this?

Upvotes: 3

Views: 3343

Answers (2)

mattyb
mattyb

Reputation: 12103

In addition to JDP10101's answer, you could alternatively consider using ExecuteStreamCommand (with a GenerateFlowFile in front of it to trigger its execution) instead. ExecuteStreamCommand writes an attribute "execution.status" that gives the exit code for the process. You could use this with RouteOnAttribute to handle success (presumably execution.status == 0) and failure (execution.status != 0)

Upvotes: 6

JDP10101
JDP10101

Reputation: 1852

ExecuteProcess is running a command outside of NiFi, so determining what "success"/"failure" is can be difficult. Depending on what your command outputs in the event of a "failure" will change what your flow logic will be.

First you probably will want to set "Redirect Error Stream" to true in order to have the error stream in the content of the FlowFile. Then you will need determine what series of characters indicates a "failure". This could be as simple as "ERROR" or more complex depending on your process. Once you determine what a "failure" means/is, use RouteText to route it off FlowFiles whose content contains those characters.

Upvotes: 2

Related Questions