I have NiFi flow that runs some shell scripts using the ExecuteStreamCommand processor and the output of the ExecuteStreamCommand is not correct.
The Shell i run is:
if (( $(ps -ef | grep -v grep | grep kibana | wc -l) > 0 )); then echo "1"; else echo "0"; fi;
if the service is up then 1 if is down then 0, simple but the output is wrong, not matter is the service is up or down the output is always 1.
Here is a demo if the flow:
@Adrian Oprea great video and that really helps eliminate a lot of questions. The result of this part of the command
$(ps -ef | grep -v grep | grep kibana | wc -l)
...does not appear to match when executed in the bash prompt versus the nifi environment. You might want to run only that part of the command in your script to see what it says in the attribute in NiFi. Also, you might want to ensure you're running in the shell you expect. You might want to have
At the top of the script, for example.
I manage to get to the bottom of it at https://stackoverflow.com/questions/48985818/apache-nifi-executestreamcommand-wrong-output , @daggett he asked to set
Ignore STDIN to
This fixed my issue.
How ever this was not very self explanatory becouse i don`t know how and why would the output be changed?!