# Exec node - Bash file - error "VCHI initialization failed"

**URL:** <https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127>\
**Category:** General\
**Created:** [7 December 2020 12:30 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127 "2020-12-07T12:30:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SimonFili](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/simonfili/32/33235_2.png) [@SimonFili](https://discourse.nodered.org/u/SimonFili)\
**Post date:** [7 December 2020 12:30 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/1 "2020-12-07T12:30:45Z")

</div>

Hi all, new here.

I simply try to run a bash one-liner and not getting the stdout of it. Read all previous post around this topic and tried many things.

My script is this:

> root@DietPi:/bin# ls -l GetTemp.bash  
> -rwxr-xr-x 1 root root 76 Dec 7 06:48 GetTemp.bash
> 
> #!/bin/bash  
> vcgencmd measure\_temp | awk -F= '{printf("%.2f%.0d\n", $2, 0)}'

Running fine on SSH:

> root@DietPi:/bin# GetTemp.bash  
> 32.60

It's executable by all, did a chmod +x on it.

In node-red, I'm using an exec node, tried with a simple "hostname" command and it works fine

When I try to run my bash GetTemp.bash, it give this:

> 07/12/2020 à 07:10:02[node: b7b7f98f.11c0a8] msg.payload : string[0]  
> ""
> 
> 07/12/2020 à 07:10:02[node: b7b7f98f.11c0a8] msg.payload : string[27]  
> "VCHI initialization failed↵"
> 
> 07/12/2020 à 07:10:02[node: b7b7f98f.11c0a8] msg.payload : Object  
> { code: 0 }

I'v tried many variations in the command box in node-red.

- bash -c GetTemp.bash
- bash -c /bin/GetTemp.bash

I changed my code to do this:

> #!/bin/bash  
> echo "hello World!"  
> vcgencmd measure\_temp | awk -F= '{printf("%.2f%.0d\n", $2, 0)}'

And I get the "hello World".. but I don't get the output of **measure\_temp**

> 07/12/2020 à 07:19:19[node: b7b7f98f.11c0a8] msg.payload : string[13]  
> "hello World!↵"
> 
> 07/12/2020 à 07:19:19[node: b7b7f98f.11c0a8] msg.payload : string[27]  
> "VCHI initialization failed↵"
> 
> 07/12/2020 à 07:19:19[node: b7b7f98f.11c0a8] msg.payload : Object  
> { code: 0 }

I'm suspecting something with awk messing my stdout somehow, so I add **tee**

> vcgencmd measure\_temp | awk -F= '{printf("%.2f%.0d\n", $2, 0)}'|tee

But still not getting the output in node-red!

I then did this:  
#!/bin/bash

> echo "hello World!"  
> vcgencmd measure\_temp | awk -F= '{printf("%.2f%.0d\n", $2, 0)}' \> /tmp/t  
> cat /tmp/t

Now in node-red I get the temperature! But also errors:

> 07/12/2020 à 07:24:45[node: b7b7f98f.11c0a8] msg.payload : string[19]  
> "hello World!↵ **34.70** ↵"
> 
> 07/12/2020 à 07:24:45[node: b7b7f98f.11c0a8] msg.payload : string[80]  
> "/bin/GetTemp.bash: line 3: /tmp/t: Permission denied↵VCHI initialization failed↵"
> 
> 07/12/2020 à 07:24:45[node: b7b7f98f.11c0a8] msg.payload : Object  
> { code: 0 }

Any clues anyone?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [7 December 2020 13:39 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/2 "2020-12-07T13:39:03Z")

</div>

```auto
Permission denied

```

node-red does (or should) not run under root and has no permissions to execute.

There is a [vcgencmd node](https://flows.nodered.org/node/node-red-contrib-vcgencmd) available, makes it perhaps a bit easier.

---

<div class="post-metadata">

**Author:** ![LosinIt](https://avatars.discourse-cdn.com/v4/letter/l/439d5e/32.png) [@LosinIt](https://discourse.nodered.org/u/LosinIt)\
**Post date:** [7 December 2020 15:44 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/3 "2020-12-07T15:44:32Z")

</div>

> [@SimonFili](#):
>
> rwxr-xr-x 1 root root 76 Dec 7 06:48 GetTemp.bash

Maybe relocate to a different path and/or change ownership?

> [@bakman2](#):
>
> There is a [vcgencmd node](https://flows.nodered.org/node/node-red-contrib-vcgencmd) available, makes it perhaps a bit easier.

Cool. Didn't know about that.

---

<div class="post-metadata">

**Author:** ![SimonFili](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/simonfili/32/33235_2.png) [@SimonFili](https://discourse.nodered.org/u/SimonFili)\
**Post date:** [7 December 2020 16:24 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/4 "2020-12-07T16:24:24Z")

</div>

Thanks for the info about the vcgencmd node, will try that.

It's not 100% accurate that the nodered user cannot execute. Since I do execute and get the output of the cat /tmp/t file. The chmod +x makes runnable by everyone.

The issue I think is related to awk and stdout running through bash... seen that before but don't remember the solution.

I did try to put the file in the nodered user directory, same issue.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [7 December 2020 19:35 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/5 "2020-12-07T19:35:43Z")

</div>

The chmod applies to the script only, not to the underlying call to vcgencmd, which in turn also needs different permissions for other subsystems.

You could solve that by adding additional permissions to the video subsystem

```auto
sudo usermod -a -G video <username - not root>

```

---

<div class="post-metadata">

**Author:** ![SimonFili](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/simonfili/32/33235_2.png) [@SimonFili](https://discourse.nodered.org/u/SimonFili)\
**Post date:** [7 December 2020 21:38 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/6 "2020-12-07T21:38:13Z")

</div>

The node does not work unfortunately

> The /usr/bin/vcgencmd command is not supported by this hardware platform

On SSH:

> root@DietPi:~# vcgencmd measure\_temp  
> temp=37.9'C  
> root@DietPi:~# which vcgencmd  
> /usr/bin/vcgencmd

I did this: usermod -a -G video nodered  
and still have this error running the bash script.

> /bin/GetTemp.bash: line 2: /tmp/t: Permission deniedVCHI initialization failed

But in the end, my script can output the temperature, so I'm good.

---

<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:** [7 December 2020 22:16 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/7 "2020-12-07T22:16:32Z")

</div>

> [@SimonFili](#):
>
> Permission deniedVCHI initialization failed

Did you see this possible answer ? [VCHI initialization failed Raspberry Pi Fixed – The Chewett blog](https://chewett.co.uk/blog/258/vchi-initialization-failed-raspberry-pi-fixed/)

---

<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:** [5 February 2021 22:16 UTC](https://discourse.nodered.org/t/exec-node-bash-file-error-vchi-initialization-failed/37127/8 "2021-02-05T22:16:36Z")

</div>

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