Can anybody explain how Output is recovered when call Exec?

#1

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?

0 Likes

#2

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. "

0 Likes

#3

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

My tests script is simple:

#!/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.

0 Likes

#4

Should work fine.. here is my test flow

[{"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":[]}]
1 Like

#5

@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.

0 Likes