# Help with exec node

**URL:** <https://discourse.nodered.org/t/help-with-exec-node/30324>\
**Category:** Dashboard\
**Created:** [19 July 2020 06:37 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324 "2020-07-19T06:37:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [19 July 2020 06:37 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/1 "2020-07-19T06:37:22Z")

</div>

I was poking around with running a python script in my raspberry pi with the exec node.  
It looks like my script was run by it but i don't think i know how to get the result crunched by my code in the msg.payload or debug tab in node red.

Can someone point me out as to what i need to do in my python code to make this show up in the debug panel of node red? My python code generates a json styled output which needs to be used to do something on the Node red dashboard.

Appreciate any help on this !  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [19 July 2020 06:49 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/2 "2020-07-19T06:49:10Z")

</div>

You just need to print what you want to push to msg.payload...  
For example print('Hello World') would appear in debug node as msg.payload....

---

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [19 July 2020 07:09 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/3 "2020-07-19T07:09:02Z")

</div>

But i am expecting a variable which is dynamic to come as the returned value after running my code  
Variable is json string with the calculated values.

Lets say my variable i want is saved in a class,  
I have "MyPort.growthValuation" which has all the json values i want.

I placed this command under

> if **name** == ' **main**':  
> MyPort = MyPortfolio()  
> MyPort.GetInfo()  
> print(MyPort.growthValuation)

I did this but the print statement doesn't show up in the Node red console window under the debug node ☹

---

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [19 July 2020 07:13 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/4 "2020-07-19T07:13:21Z")

</div>

You can freely develop your python script as normal, test it via python filename.py and once you see in your tests the values you want to push to node-red just run it trought exec node...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 July 2020 07:23 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/5 "2020-07-19T07:23:59Z")

</div>

> [@kvramji](#):
>
> the print statement doesn't show up in the Node red console window under the debug node

Have you checked all three outputs of the exec node to see what is there? Use three debug nodes configured to Show Complete Message and give them names so you can identify them in the debug pane.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 July 2020 07:24 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/6 "2020-07-19T07:24:25Z")

</div>

As per the info panel you made need -u option on Python to stop it buffering its output.

---

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [19 July 2020 07:29 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/7 "2020-07-19T07:29:48Z")

</div>

Ah Yes, My output came in the 1st output node  
Will keep this in mind !

Thanks @Colin

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [20 July 2020 04:17 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/8 "2020-07-20T04:17:43Z")

</div>

I find it much easier to add MQTT support to a python script, and have said script run as a service. Then use NR to request and receive from the python (service) via MQTT. Not to say that exec method is not an option, but having python talk MQTT to and from NR is much easier in the long run, IMHO.

---

<div class="post-metadata">

**Author:** ![kvramji](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kvramji/32/59005_2.png) [@kvramji](https://discourse.nodered.org/u/kvramji)\
**Post date:** [20 July 2020 05:18 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/9 "2020-07-20T05:18:11Z")

</div>

That is actually a wonderful idea !  
MQTT is the easiest thing to work with. Since the script runs on my raspberry pi i can make use of crontab to run it at fixed intervals and spit out the information using MQTT  
Thanks @Nodi.Rubrum

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [20 July 2020 05:30 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/10 "2020-07-20T05:30:13Z")

</div>

You are welcome. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 August 2020 05:30 UTC](https://discourse.nodered.org/t/help-with-exec-node/30324/11 "2020-08-03T05:30:15Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
