The alternative to running a script once a second (as in my other question) is to use a script that's setuid root - nasty and most systems don't let you do it.
I'll explain the problem, I'm reading some analog inputs on a Beaglebone Black and want to display them on a numeric LCD. It's basically a voltmeter and ammeter. Thus I want the display to update fairly frequently.
The underlying problem is that because of the (stupid?) way the Beaglebone is configured you have to be root to read the ADC inputs. Thus my original solution was to have a root task running in the background reading the ADC values once a second and writing them to a world readable file. The user task can then read them from file as necessary and display the values or send them to me or whatever.
The alternative would be to provide some sort of callable routine that runs with root privilege which can be called as needed from user tasks. This would be a much more elegant solution really as much of the time I don't need 'once a second' frequency, only once an hour for sending values across the internet. It's only when I'm in the same place as the Beaglebone that I want 'once a second' values that I can look at.
Is there a neat way of running a bit of Python code with root privilege? Security really isn't terribly important, it's only a little SBC monitoring some values.
I suppose I could simply run everything as root but that feels all wrong somehow! :-)