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?