Nifi executeprocess processor

3.1k Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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)

0
On

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.