Support Questions

Find answers, ask questions, and share your expertise

NiFi ExecuteCommandStream with sed

avatar
Explorer

I'm trying to run a sed command through a ExecuteCommandStream but I get the error pasted below. The ExecuteCommandStream has the input from a EvaluateXPath processor. How do I give the flowfile argument? I'm getting this error:

 

ExecuteStreamCommand[id=9c7cfd48-0171-1000-1a59-064ce951124a] Transferring flow file StandardFlowFileRecord[uuid=e448ca5a-8dc8-4754-a0d4-549db92d1f79,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1587501858734-9104, container=default, section=912], offset=375435, length=-1],offset=0,name=DL_prelchim1971_20190302_142639_20190302_145642.xml,size=0] to nonzero status. Executable command sed ended in an error: Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file].

 

sedp.jpg

1 ACCEPTED SOLUTION

avatar
Explorer

You have to provide full path of your script in "Command Path" Attribute. 

All the flowfile arguments can be passed in "Command Arguments" Property.

 

In below example, I am considering that I have a shell script created under /tmp directory with the name yourscript.sh

This script should have all the logics inside to handle receiving arguments and other logics. 

 

Vj1989_0-1587904660363.png

 

Script Content (/tmp/yourscript.sh)

 

#!/bin/bash

echo $1

 

Expected Output: Just print the name of the FlowFile inside the flow file content.

 

You may check this video for complete detail:
https://www.youtube.com/watch?v=rUJOS6LT5Jk&t=27s

View solution in original post

2 REPLIES 2

avatar
Explorer

You have to provide full path of your script in "Command Path" Attribute. 

All the flowfile arguments can be passed in "Command Arguments" Property.

 

In below example, I am considering that I have a shell script created under /tmp directory with the name yourscript.sh

This script should have all the logics inside to handle receiving arguments and other logics. 

 

Vj1989_0-1587904660363.png

 

Script Content (/tmp/yourscript.sh)

 

#!/bin/bash

echo $1

 

Expected Output: Just print the name of the FlowFile inside the flow file content.

 

You may check this video for complete detail:
https://www.youtube.com/watch?v=rUJOS6LT5Jk&t=27s

avatar
Explorer

I've already checked this material before, thank you!

I didn't manage to fully apply it to my case. I have xml input flowfiles and need to do some text replace and after that push them foward in the flow.