Support Questions

Find answers, ask questions, and share your expertise

how to give full permission to files which groovy script creates dynamically in Nifi


Hi Team,

I am creating year date time folder thru groovy ExecuteScript processor and using command execute using creating sh file and writing some content in that.. and passing that sh file to downstream ExecuteStreamCommand processor. Its failing with permission error on sh file.

How to give full permission to the file which we create.


def commmnd1 = "mkdir -p /shared_path/data/poc/test/1/script"
def commmnd3 = "mkdir -p /shared_path/data/poc/test/1/output"

def process1 = commmnd1.execute();
def process3 = commmnd3.execute();

def filePath = "${script_dir}/"
def file2 = new File(filePath)
file2.write "#!/bin/bash\n";

and one more, ExecuteStreamCommand executing sh file and it generating some files in dynamically created by previous ExecuteScript processor and these are files does not have full permission. How to give full permission which we create folder and files dynamically.


Please suggest.


Thanks in Advance. 


Master Guru

What is important to understand is that the NiFi component processors are not being executed by the user authenticated (assuming secured NiFi) into NiFi, but rather by the NiFi service user.  
So let's say that your NiFi service is owned by a "nifiservice" linux account.   Whatever umask is configured for that user will be applied to directories and files create by that user.   Now if your script is using sudo, it is changing the user that executes your script resulting in different user ownership and permission from the "nifiservice" user.   Subsequent component processors will also execute as the "nifiservice" user and then not have access to those files and directories.    So you'll need to take this in to account as you built your scripts.  Make sure that your scripts are adjusting permissions on the directory tree and files as needed so your "nifiservice" user or all users can access the files needed downstream in your dataflows.  So in yoru case it sounds like your script executed by ExecuteScript processor is creating a sh file not owned by the "nifiservice" user or does not have execute permission set on it.  The ExecuteStreamCommand processor will attempt to execute the sh command on disk as the "nifiservice" user only.

If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.

Thank you,


Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.