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.

How to pass python program as string to interpreter in ExecuteStreamCommand

How to pass python program as string to interpreter in ExecuteStreamCommand

New Contributor

Unlike ExecuteScript processor, the ExecuteStreamCommand does not have 'Script Body' attribute that gets passed during execution. Is there is any workaround where we can pass program as a string? I tried with command 'Python -c .. '. But no luck

 

#ExecuteStreamCommand #ScriptBody #ScriptBodyAttribute 

2 REPLIES 2
Highlighted

Re: How to pass python program as string to interpreter in ExecuteStreamCommand

Super Mentor

@MortyCodes 

Just to confirm .. you want to pass a Python program file name to the "ExecuteStreamCommand" Processor?

 

ExecuteStreamCommand  Properties.

Command Arguments: /Jay/NifiDemo/test_python.py
Command Path:   /bin/python
Argument Delimiter:  ;

 

I tried with the above approach and i can see the script is getting executed fine.

Is that something what you are looking out for?
NiFi_ExecuteStreamCommand.png
.

 

Re: How to pass python program as string to interpreter in ExecuteStreamCommand

New Contributor

Thanks for the response @jsensharma 

 

I do not want point to a python script file and invoke the interpreter.

 

I have scenario where python code is present in flowfile attribute or a variable and want to run it in ExecuteStreamCommand processor. I can not use ExecuteScript processor because it invokes Jython based interpreter. Am using ExecuteStreamCommand processor as I want to explicitly invoke Python 3.5 interpreter.

 

If there is no workaround, What is standard way for having script location. Placing the script file in NiFi server might be risk because other users might accidentally modify/delete it. How to avoid it?

Don't have an account?
Coming from Hortonworks? Activate your account here