Skip to main content
Techie123
Silver ⭐️⭐️⭐️
Jun 14, 2022 12:23 PM UTC
Solved

how to add output stream relationship result of Execute Stream Command processor into original flow file

 

I need a help, I am new to NiFi. I am using python script. I wanted to add output stream relationship result of ExecuteStreamCommand processor into original flow file. In original file I am getting body and the script is generating users information. Please help me

SAMSAL
SAMSALAnswer
Platinum ⭐️⭐️⭐️
Jun 14, 2022 5:06 PM UTC

first you need to check if there is an attribute called filename on the original flowfile and its the same passed the output stream flowfile. If there is, then you should specify it as "filename" in the merge content property and NOT as "${filename}".

11 replies

MattWho
Titanium ⭐️⭐️
Titanium ⭐️⭐️
Jun 14, 2022 12:57 PM UTC

@Techie123 

The ExecuteStreamCommand processor is working as designed:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.16.2/org.apache.nifi.processors.standard.ExecuteStreamCommand/index.html

Executes an external command on the contents of a flow file, and creates a new flow file with the results of the command.


You could route both the "original" and "output stream " relationships via the same outbound connection to a mergeContent processor which can merge the content from both source FlowFiles into a single FlowFile.
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.16.2/org.apache.nifi.processors.standard.MergeContent/index.html

 

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt

Translate
Techie123
Techie123Author
Silver ⭐️⭐️⭐️
Jun 14, 2022 1:29 PM UTC

Yes. But the thing is script is generating token decryption result and original flow file contains body. But the merge content processor is merging flow files randomly 

Translate
Techie123
Techie123Author
Silver ⭐️⭐️⭐️
Jun 14, 2022 1:35 PM UTC

@MattWho , can we append output stream result to original flow file without using mergeContent processor because the we have multiple incoming flow files and i just wanted to append two at a time, original flow file with the output stream result  

Translate
SAMSAL
Platinum ⭐️⭐️⭐️
Jun 14, 2022 1:01 PM UTC

Hi,

Not sure I fully understand your question. Can you please provide screenshot of the flow you have and explain the expected output of each processor? From what I can understand you want to keep the original file but somehow you want to attach the output of the command stream to it. There is property on the ExecuteCommandStream Processor called "Output Destination Attribute" where you can store the output stream as an attribute on the original flow file. if you want to modify the content of the flow file after that based on the new attribute then you can use ExecuteScript Processor.

 

Translate
Techie123
Techie123Author
Silver ⭐️⭐️⭐️
Jun 14, 2022 1:32 PM UTC

Hi @SAMSAL , it should not return as an attribute but the data, because the output stream contains decrypted data and the original flow file also has the some important data

Translate