# Can anybody explain how Output is recovered when call Exec?

**URL:** <https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707>\
**Category:** General\
**Created:** [2 April 2019 22:00 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707 "2019-04-02T22:00:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelv1n](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kelv1n](https://discourse.nodered.org/u/kelv1n)\
**Post date:** [2 April 2019 22:00 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/1 "2019-04-02T22:00:21Z")

</div>

Hi Guys

I'm using Exec to call a python script, but for some reason, when I output using print(), its not being returned to Node-RED. Yet, it receives the debug output from using the logging library - I've also tried sending output to sys.stdout.write() and sys.stderr.write() and neither of then are returned.

I'm going to do a bit more digging - But I was wondering if anybody could offer some insight or suggestions?

---

<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:** [2 April 2019 22:27 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/2 "2019-04-02T22:27:43Z")

</div>

Hi, I know it's a big read - the last line of the exec node info panel on the right is...

" Tip: if running a Python app you may need to use the `-u` parameter to stop the output being buffered. "

---

<div class="post-metadata">

**Author:** ![kelv1n](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kelv1n](https://discourse.nodered.org/u/kelv1n)\
**Post date:** [2 April 2019 23:11 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/3 "2019-04-02T23:11:33Z")

</div>

Thanks dceejay, I was praying that would work, but its still not working.

My tests script is simple:

```auto
#!/usr/bin/python3 -u
import os
print("Test Out....")

```

I've tried calling the script directly, and also with the python interpreter.

python -u /vm-scripts/test.py

I did also try using the pythonshell node, which did work for returning the output, but I ran into a different issue, in I cannot easily pass parameters to the script with this.

---

<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:** [2 April 2019 23:23 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/4 "2019-04-02T23:23:24Z")

</div>

Should work fine.. here is my test flow

```auto
[{"id":"bcb67ebc.b1eca","type":"inject","z":"ff27ff95.cc8d5","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":149,"y":847,"wires":[["24eae0e2.b038"]]},{"id":"24eae0e2.b038","type":"exec","z":"ff27ff95.cc8d5","command":"python","addpay":false,"append":"-u /tmp/test.py","useSpawn":"false","timer":"","oldrc":false,"name":"","x":299,"y":847,"wires":[["8647d03c.afbcb"],[],[]]},{"id":"8647d03c.afbcb","type":"debug","z":"ff27ff95.cc8d5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":469,"y":847,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![kelv1n](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@kelv1n](https://discourse.nodered.org/u/kelv1n)\
**Post date:** [3 April 2019 17:53 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/5 "2019-04-03T17:53:31Z")

</div>

@dceejay you sir, are a **superstar** , thank you so much. I was pulling my hair out with this for the past several evenings.. My mistake it seems, I was putting the full path script in the "Command" field.

---

<div class="post-metadata">

**Author:** ![Amit2016-17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/amit2016-17/32/35782_2.png) [@Amit2016-17](https://discourse.nodered.org/u/Amit2016-17)\
**Post date:** [24 January 2021 14:50 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/6 "2021-01-24T14:50:26Z")

</div>

Its not working

Command failed: python3 1611499717485 -u dht\_simpletest.pypython3: can't open file '1611499717485': [Errno 2] No such file or directory

do we need to use different command when node=red is installed on docker , I am using IOTstack on docker

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [24 January 2021 14:59 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/7 "2021-01-24T14:59:57Z")

</div>

Did you leave the append msg.payload option checked? Because this looks like you by accident appended a timestamp (probably from the inject node) to your commands.  
But please open a new thread for questions like this as its no good appending your question to a two year old thread.

---

<div class="post-metadata">

**Author:** ![Amit2016-17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/amit2016-17/32/35782_2.png) [@Amit2016-17](https://discourse.nodered.org/u/Amit2016-17)\
**Post date:** [24 January 2021 20:20 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/8 "2021-01-24T20:20:07Z")

</div>

Have you figured out why it was not running

---

<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:** [24 January 2021 21:54 UTC](https://discourse.nodered.org/t/can-anybody-explain-how-output-is-recovered-when-call-exec/9707/9 "2021-01-24T21:54:53Z")

</div>

Look at the command it was trying to run, it is in the error message. Is that the command you want to run?
