Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Assign an attribute to the output of ExecuteStreamCommand.

Solved Go to solution

Assign an attribute to the output of ExecuteStreamCommand.

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

Accepted Solutions

Re: Assign an attribute to the output of ExecuteStreamCommand.

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).

3 REPLIES 3
Highlighted

Re: Assign an attribute to the output of ExecuteStreamCommand.

Expert Contributor

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

Re: Assign an attribute to the output of ExecuteStreamCommand.

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

Re: Assign an attribute to the output of ExecuteStreamCommand.

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).