Hi!
I cannot get this working from node red...
when i run this "sudo ./fm_transmitter -f 102.7 acoustic_guitar_duet.wav" in the dir "/home/pi/fm_transmitter/"
It works on command line
but when i do the following from the exec node i get an error, what is run with my thinking??
"sudo ~/home/pi/fm_transmitter/fm_transmitter -f 102.7 acoustic_guitar_duet.wav"
i found that ./ is just the current directory, so i tried to run the commend in the directory without ./ but then it is also not working
./ is a relative path so it will be a different path from wherever you are on the command line. Inside Node-RED, you are inheriting the location of Node-RED.
You should generally use absolute paths when working with files inside Node-RED.
There should not be a ~ on the front.
So first check that running this in a terminal works (no ~) sudo /home/pi/fm_transmitter/fm_transmitter -f 102.7 acoustic_guitar_duet.wav
If it does then does it ask for a password?
In fact you probably need to put the full path on the wav file too so sudo /home/pi/fm_transmitter/fm_transmitter -f 102.7 /home/pi/fm_transmitter/acoustic_guitar_duet.wav
That's horrible, putting the password in plain text in the flow file, though I suppose you could insist on it being entered via the dashboard each time which wouldn't be quite so bad.
Have you specifically disabled it for the node red user for that command or have you completely disabled password with sudo. If you have completely disabled it then I hope you realise the security implications of that.
An even better way is to give a particular user group access to whatever resources the command needs that normally requires sudo, then the node-red user would not need to use sudo with that command.
Haha, I did stress the if you really must part. Didn't say it was best, just that you can.
You can always use a credential and insert it to the flow data. That wouldn't be too bad, good enough for most things. I wouldn't have any exec nodes in flows that might be accessible from the Internet in any case.
I thought raspbian had stopped allowing sudo without password, but maybe it is only on raspbian lite that this is true, or maybe I am completely wrong.
In practice it probably isn't much of an issue as long as nothing on your network (in particular node-red) is accessible from the internet, or by possibly malicious users via the wifi.
Well, it is just a setting away even if they have. I've not installed a Buster version of Rasbian so I don't know myself.
I'm moving onto Debian Buster on an old(ish) Lenovo x240 laptop. I finally outgrew my 2 Pi's. The alternative was a 4GB Pi 4 but it wasn't worth the money for me. 8GB RAM and an i5 makes a nice platform and not too power hungry as it is a slim laptop with the screen off and set to low-power CPU mode.