Created on 04-24-2018 08:33 PM - edited 08-17-2019 06:29 PM
I have created a Shellscript and It requires three arguments to be passed . It was working fine till I execute it in a terminal . When I configured using Nifi ExecuteProcess ,nifi is ignoring the arguments .
Example :/tmp/script.sh 1 2 8
Refer the attached image . How can I inform nifi to look at the arguments for shell script.
Or kindly advice me to use anyother processor with detailed steps . Since this is not my strongest point .
Thanks!!
Created on 04-25-2018 01:18 AM - edited 08-17-2019 06:29 PM
You can use Execute Process (or) Execute Stream Command processors to pass arguments to the shell script.
Execute Process Processor:-
This processor won't need any upstream connections to trigger the script i.e this processor can run its own based on the schedular.
Example:-
I'm having sample script which gets 2 command line arguments and echo output.
bash$ cat sample_script.sh #!/bin/bash echo "First arg: $1" echo "Second arg: $2"
Execution in terminal:-
bash$ ./sample_script.sh hello world First arg: hello Second arg: world
1.Execution in NiFi using ExecuteProcess Processor:-
Command
bash
Command Arguments
/tmp/sample_script.sh hello world //here we are triggering the shell script and passing arguments with space
Batch Duration No value set Redirect Error Stream
false
Argument Delimiter
space //by default
if Argument Delimiter is
;
then command arguments would be
/tmp/sample_script.sh;hello;world
Configs:-
Success relation from ExecuteProcess will output the below as content of flowfile
First arg: hello Second arg: world
2.Execution in NiFi using ExecuteStreamCommand processor:-
This processor needs some upstream connection to trigger the script.
Flow:-
We have used generateflowfile processor as a trigger to ExecuteStreamCommand script
Generateflowfile Configs:-
Added two attributes arg1,arg2 to the flowfile
ExecuteStreamCommand processor:-
Command Arguments
${arg1};${arg2}
Command Path
/tmp/sample_script.sh
Argument Delimiter
;
Now we are using the attributes that added in generateflowfile processor and passing them to the script.
Use the OutputStream relation from ExecuteStreamCommand processor and the output flowfile content would be same
First arg: hello Second arg: world
By using these processors you can trigger the shell script and pass the arguments also.
-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.
Created on 04-25-2018 01:18 AM - edited 08-17-2019 06:29 PM
You can use Execute Process (or) Execute Stream Command processors to pass arguments to the shell script.
Execute Process Processor:-
This processor won't need any upstream connections to trigger the script i.e this processor can run its own based on the schedular.
Example:-
I'm having sample script which gets 2 command line arguments and echo output.
bash$ cat sample_script.sh #!/bin/bash echo "First arg: $1" echo "Second arg: $2"
Execution in terminal:-
bash$ ./sample_script.sh hello world First arg: hello Second arg: world
1.Execution in NiFi using ExecuteProcess Processor:-
Command
bash
Command Arguments
/tmp/sample_script.sh hello world //here we are triggering the shell script and passing arguments with space
Batch Duration No value set Redirect Error Stream
false
Argument Delimiter
space //by default
if Argument Delimiter is
;
then command arguments would be
/tmp/sample_script.sh;hello;world
Configs:-
Success relation from ExecuteProcess will output the below as content of flowfile
First arg: hello Second arg: world
2.Execution in NiFi using ExecuteStreamCommand processor:-
This processor needs some upstream connection to trigger the script.
Flow:-
We have used generateflowfile processor as a trigger to ExecuteStreamCommand script
Generateflowfile Configs:-
Added two attributes arg1,arg2 to the flowfile
ExecuteStreamCommand processor:-
Command Arguments
${arg1};${arg2}
Command Path
/tmp/sample_script.sh
Argument Delimiter
;
Now we are using the attributes that added in generateflowfile processor and passing them to the script.
Use the OutputStream relation from ExecuteStreamCommand processor and the output flowfile content would be same
First arg: hello Second arg: world
By using these processors you can trigger the shell script and pass the arguments also.
-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.