How to send a Terminal command to Raspbian?

Hi there,

i´d like to send a Terminal comand (in my case "export DISPLAY=:0.0" and "xrandr --output HDMI-1 --off")

How can i do this from Node Red ?

the exec node is for executing shell commands.

yes that´s what i tried, but it shows me "ERROR:1". What does that mean?

i put in: sudo xrandr --output HDMI-1 --off #

also without sudo or # still the same error. Any idea why?

--->> I see that there´s a second comand missing. I read that a "&&" can adapt two comands. so i send the following:

sudo export DISPLAY=:0.0 && xrandr --output HDMI-1 --off #

Is it correct?

you would have saved me stating that if you included that up front. :man_shrugging:

this is really a linux issue (not a node-red issue) but we can try to help.

The error could be any number of things but likely down to environment.

Try putting the full path of xrandr in the command

e.g: DISPLAY=:0 /usr/bin/xrandr --output HDMI-1 --off in the payload.

use which xrandr to get the path you your xrandr!

Next, is the user running node-red the same user running display service?


Tip: Send env to an exec node (then to a debug node) to see what environment node-reds shell has - see if that gives you any clues.


In short, this is a "your system" thing - the exec node will do as it is told :wink:

1 Like

I got it ... it should be

export DISPLAY=:0.0 && xrandr --output HDMI-1 --off

without sudo and #

Before i update my Raspberry from Bullseye to Bookworm it was

vcgencmd display_power 1 #

anyway it works.

Thank you for your quick responce !

1 Like

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