EXEC Node Run Python in FOREGROUND

Hello.
I have python script to communicate with serial port.
I start this script using EXEC-NODE: "python3 /home/pi/pyscript/pyscript.py"
In processes the running script is there as python3.
But it is running in BACKGROUND.
How can I start the python script in FOREGROUND in TERMINAL?

Thanks. BR.

Hi farcry, welcome to the forum.

Out of curiosity, what is your python script doing that node-red cannot?

I ask as there may be a way to do it all in node-red and avoid spawning python processes altogether.

It is communicating via USB port through XBee to Zigbee.
This python script does all the configurations of XBee and decodes the data received from the Zigbee End device (aqira rHT sensor).

Why do you want to run it in a foreground terminal and why don't you just run the script separate from node-red?

The way to start a command prompt from the EXEC node like you ask is like this example taken from my system. Here I'm using uxterm to be able to set the size and position on the display. The display number is normally 0 but if you have several displays, you may have to pick another number

2 Likes

Thanks for solution but unfortunately it is not working for me.
I've got error: -2.
I'm using Debian running on rpi3+

Try the command directly in a command prompt and check what error you get

export DISPLAY....

Hello. I replaced uxterm with lxterminal

If I run this command in terminal it opens another terminal and starts running.
export DISPLAY=:0 && lxterminal -e python3 /home/pi/zigpy/AP_3.py

In exec node It ends with Error: -2

I also add this to py file:

import os
os.environ["DISPLAY"] = ':0'
os.environ["XAUTHORITY"] = '/home/user/.Xauthority'

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