Exec node with sudo rights?

2,441 views
Skip to first unread message

bad...@gmail.com

unread,
Mar 30, 2014, 3:40:46 PM3/30/14
to node...@googlegroups.com
Hi,

I'm interacting with sensors on a Raspberry Pi via a Python script, which requires sudo rights. The data gets into Node-RED via UDP. The hardware seems to have occasional hick ups, and the script stalls. This triggers an event in Node-RED, but now I'm stuck: Manually, I issue 'sudo killall python' and 'sudo python sensors.py' - but can I do this automatically from within my flow?

Any hints much appreciated!

Boris

Dave C-J

unread,
Mar 30, 2014, 5:20:40 PM3/30/14
to node...@googlegroups.com
Hi,

well several dodgy options... so read around each first...
1) run Node-RED as root....
4) re-write the sensor code in Node-RED also ;-)




Boris

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
regards

Dave Conway-Jones

li...@amcc.myzen.co.uk

unread,
Mar 31, 2014, 4:51:23 AM3/31/14
to node...@googlegroups.com
Hi Boris,

You might be able to avoid the need to run the python script as root (depending on what it's trying to do) by adding the logged in user to some extra groups.

e.g. to read /dev/ttyUSB* files

sudo adduser boris dialout

or to access gpio and/or spi on Raspberry Pi

sudo adduser boris gpio spi

You need to logout and login again before it takes effect.

To see which groups you're in type

groups

Regards,
Aideen

bad...@gmail.com

unread,
Mar 31, 2014, 6:04:46 AM3/31/14
to node...@googlegroups.com
I love the way CJ calls them "dodgy options", because that's exactly how I feel about them. Aideen's suggestion is on my try-out list for tonight. I'm going to avoid the 'killall' step by rebooting the Pi into Node-RED and let the exec node take care of starting the Python command.

All part of the big "Node-RED interoperability with data silos" review.

Boris

chris mobberley

unread,
Apr 1, 2014, 5:04:27 AM4/1/14
to node...@googlegroups.com
I have to say I am one of those using the run node-red as sudo dodgy workers. I had so many headaches with trying to work with a very similar situation to yourself. I set up a new user and group to run node-red under and I ended up elevating the rights so much I may as well have just stuck with sudo. Granted my linux skills are dire..as are most of my skills come to think of it, so there may be another fix but it didn't warrant me losing hours of my life to just for the sake of running sudo. I'm sure "hackers" care more about other stuff than my raspberry pi home server..

Dave C-J

unread,
Apr 1, 2014, 8:48:31 AM4/1/14
to node...@googlegroups.com
Chris,

just because I said it's dodgy and advise against doing it... doesn't mean I don't ;-) - just be aware of the risks.


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
regards

Dave Conway-Jones

Peter Scargill

unread,
Aug 21, 2016, 1:48:32 PM8/21/16
to Node-RED
Adding users to the gpio group is good for Raspberry Pi but no good for many other similar boards that don't have that group.

Peter Scargill

unread,
Aug 21, 2016, 6:09:49 PM8/21/16
to node...@googlegroups.com

There is no gpio group – only have that on a Raspberry Pi.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/82-KeIfIIoU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Reply all
Reply to author
Forward
0 new messages