# How to send a Terminal command to Raspbian?

**URL:** <https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382>\
**Category:** General\
**Created:** [14 October 2024 16:48 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382 "2024-10-14T16:48:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [14 October 2024 16:48 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382/1 "2024-10-14T16:48:34Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 October 2024 16:56 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382/2 "2024-10-14T16:56:03Z")

</div>

the `exec` node is for executing shell commands.

---

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [14 October 2024 17:10 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382/3 "2024-10-14T17:10:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 October 2024 17:19 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382/4 "2024-10-14T17:19:10Z")

</div>

> [@Flixm](#):
>
> yes that´s what i tried,

you would have saved me stating that if you included that up front. 🤷‍♂️

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 😉

---

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [14 October 2024 17:25 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382/5 "2024-10-14T17:25:26Z")

</div>

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 !

---

<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:** [28 October 2024 17:25 UTC](https://discourse.nodered.org/t/how-to-send-a-terminal-command-to-raspbian/92382/6 "2024-10-28T17:25:47Z")

</div>

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