I'm trying to get the ip-adres of the raspberry pi which my node-red server is running on (it has Rhasspy running on it too, so I'll be able to ask for it, but that is not the issue).
I use this bash-command:
/sbin/ip -4 -o addr show dev eth0| /usr/bin/awk '{split($4,a,"/");print a[1]}'
which runs fine in the linux-terminal
However when I put it in an exec-node in node-red, it no longer works.
This is my flow:
ty[{"id":"aa7ebe61.f0a9f","type":"tab","label":"WhatsMyIp","disabled":false,"info":""},{"id":"507071fb.dfcf78","type":"debug","z":"aa7ebe61.f0a9f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":120,"wires":[]},{"id":"4c8ca89e.31f138","type":"exec","z":"aa7ebe61.f0a9f","command":"/sbin/ip -4 -o addr show dev eth0| /usr/bin/awk '{split($4,a,\"/\");print a[1]}'","addpay":true,"append":"","useSpawn":"false","timer":"20","oldrc":false,"name":"GetIp","x":310,"y":160,"wires":[["507071fb.dfcf78"],["988934e3.be1e48"],["a82d10e4.9c853"]]},{"id":"988934e3.be1e48","type":"debug","z":"aa7ebe61.f0a9f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":160,"wires":[]},{"id":"a82d10e4.9c853","type":"debug","z":"aa7ebe61.f0a9f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":200,"wires":[]},{"id":"db06641a.216ec8","type":"inject","z":"aa7ebe61.f0a9f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":260,"wires":[["4c8ca89e.31f138"]]}]pe or paste code here
I resorted to this approach because the node-red-contrib-get-my-ip fails to install.
kind regards,
Hugo