Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Assign an attribute to the output of ExecuteStreamCommand.

avatar
Expert Contributor

Hi, i have a custom program producing an integer output when using an ExecuteScriptCommand. I am trying to assign the integer an attribute with UpdateAttribute processor but its not working? How could i go about this, thank you

1 ACCEPTED SOLUTION

avatar
Master Guru

If your configuration of ExecuteStreamCommand outputs an integer and you would like it in an attribute, try setting the "Output Destination Attribute" property of ExecuteStreamCommand to the attribute name you'd like, and use the "original" relationship to transfer the flow file downstream. That will give you a flow file with the same incoming content as well as an attribute whose name is of your choosing and whose value is the output stream returned (hopefully the same value you mention your command returns) by the command you are executing. If instead you want the exit code of the command, you will find it in the "execution.status" attribute of the outgoing flow file (see doc here).

View solution in original post

4 REPLIES 4

avatar
Super Collaborator

The description of Nifi functions ends with the statement,

After evaluating expression language functions, all attributes are stored as type String.

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#functions

How do you plan to use the attribute down stream?

If you're just looking for a way to have your output become an attribute, the following page has a nice example,

http://funnifi.blogspot.com/2016/02/executescript-processor-hello-world.html

avatar
Expert Contributor

hi @bhagan i want my output to become an attribute, but im having trouble assigning it an attribute with update attribute processor. What do i assign as my value? ${output stream} doesnt work

avatar
Master Guru

If your configuration of ExecuteStreamCommand outputs an integer and you would like it in an attribute, try setting the "Output Destination Attribute" property of ExecuteStreamCommand to the attribute name you'd like, and use the "original" relationship to transfer the flow file downstream. That will give you a flow file with the same incoming content as well as an attribute whose name is of your choosing and whose value is the output stream returned (hopefully the same value you mention your command returns) by the command you are executing. If instead you want the exit code of the command, you will find it in the "execution.status" attribute of the outgoing flow file (see doc here).

avatar
New Contributor

Hi,

i am trying to get an ArrayList as an output of the ExecuteStreamCommand Processor using Java  but I am neither getting it in the output destination attribute nor anything in the execution.status. I tried testing it with assigning an Integer too but did not work.Can you tell me if I am missing something here.