Re: Simple way for web to execute root shell script.

Liste des GroupesRevenir à cs raspberry-pi 
Sujet : Re: Simple way for web to execute root shell script.
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.os.linux.misc comp.sys.raspberry-pi
Date : 24. May 2025, 03:13:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <100ra17$bv9e$1@dont-email.me>
References : 1 2 3
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
In comp.os.linux.misc The Natural Philosopher <tnp@invalid.invalid> wrote:
On 23/05/2025 19:44, Rich wrote:
In comp.os.linux.misc The Natural Philosopher <tnp@invalid.invalid> wrote:
I have a shell script that monitors hardware stuff - it needs to run
as root and be called by Apache as user www.
>
  Bookworm linux on a Pi4.
>
Its all inside a domestic firewall so security is not a huge issue.
What is the quickest and simplest solution to this?
 
You've been given lots of options already.  But not this one.
 
What "hardware stuff" is it monitoring?  If it is reading files in
/proc and/or /sys to obtain its "data" then another alternative would
be to setup /proc and /sys to be mounted group or world readable (or to
reset permissions on the necessary files via a rc.local boot script to
group or world readable).  That would let the script "monitor" without
being root.  Then you could even convert the script into a CGI script
(which Apache is more than able to execute, and doing so for minimal
text output involves the script outputting a handful of HTTP headers
before the monitor data) and get your "monitoring data" back via
Apache.
 
Sadly the data is not available in /sys or /proc AFAIK.

Yeah, at least the smart data is not (as far as I am aware) available
via /proc or /sys.

Another option.  You could setup a cronjob, as root, to run your script
on some periodic basis (once per minute, every 10 minutes, etc.) and
save the results into a file that is readable via the 'www' user (or to
save the info directly into a file in the Apache htdocs hierarchy from
where you want to retreive it).

Then you can 'pull' the data via Apache from that file.

You'd have data that is up to date as of the last run of the script,
but you would not have the "exactly now it is Y" aspect (unless your
AJAX pulled just after a cronjob run *and* you were watching the
'meters' at that very moment).

You could even include a "date" as the first line, so you could see if
something got hung by the time value being too far in the past.


Date Sujet#  Auteur
23 May 25 * Simple way for web to execute root shell script.48The Natural Philosopher
23 May 25 +* Re: Simple way for web to execute root shell script.4Pancho
23 May 25 i+* Re: Simple way for web to execute root shell script.2Lew Pitcher
23 May 25 ii`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May 25 i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May 25 +* Re: Simple way for web to execute root shell script.7Lew Pitcher
23 May 25 i+* Re: Simple way for web to execute root shell script.2Lew Pitcher
23 May 25 ii`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May 25 i`* Re: Simple way for web to execute root shell script.4The Natural Philosopher
23 May 25 i `* Re: Simple way for web to execute root shell script.3Marc Haber
23 May 25 i  +- Re: Simple way for web to execute root shell script.1The Natural Philosopher
24 May 25 i  `- Re: Simple way for web to execute root shell script.1Lawrence D'Oliveiro
23 May 25 +* Re: Simple way for web to execute root shell script.2John-Paul Stewart
23 May 25 i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May 25 +- Re: Simple way for web to execute root shell script.1Eli the Bearded
23 May 25 +* Re: Simple way for web to execute root shell script.21Rich
23 May 25 i`* Re: Simple way for web to execute root shell script.20The Natural Philosopher
24 May 25 i +* Re: Simple way for web to execute root shell script.2Rich
24 May 25 i i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
24 May 25 i +- Re: Simple way for web to execute root shell script.1Theo
24 May 25 i +- Re: Simple way for web to execute root shell script.1Chris Elvidge
25 May 25 i `* Re: Simple way for web to execute root shell script.15Anssi Saari
25 May 25 i  `* Re: Simple way for web to execute root shell script.14The Natural Philosopher
25 May 25 i   +* Re: Simple way for web to execute root shell script.3Lawrence D'Oliveiro
29 May 25 i   i`* Re: Simple way for web to execute root shell script.2vallor
29 May 25 i   i `- Re: Simple way for web to execute root shell script.1The Natural Philosopher
26 May 25 i   `* Re: Simple way for web to execute root shell script.10Anssi Saari
26 May 25 i    +- Re: Simple way for web to execute root shell script.1The Natural Philosopher
27 May 25 i    `* Re: Simple way for web to execute root shell script.8druck
28 May 25 i     `* Re: Simple way for web to execute root shell script.7The Natural Philosopher
28 May 25 i      `* Re: Simple way for web to execute root shell script.6druck
29 May 25 i       +* Re: Simple way for web to execute root shell script.4Anssi Saari
29 May 25 i       i`* Re: Simple way for web to execute root shell script.3The Natural Philosopher
30 May 25 i       i `* Re: Simple way for web to execute root shell script.2Anssi Saari
30 May 25 i       i  `- Re: Simple way for web to execute root shell script.1The Natural Philosopher
29 May 25 i       `- Re: Simple way for web to execute root shell script.1The Natural Philosopher
23 May 25 +- Re: Simple way for web to execute root shell script.1druck
24 May 25 +- Re: Simple way for web to execute root shell script.1Lawrence D'Oliveiro
24 May 25 +* Re: Simple way for web to execute root shell script.6The Natural Philosopher
24 May 25 i+* Re: Simple way for web to execute root shell script.4Richard Kettlewell
24 May 25 ii+- Re: Simple way for web to execute root shell script.1The Natural Philosopher
24 May 25 ii`* Re: Simple way for web to execute root shell script.2Eli the Bearded
24 May 25 ii `- Re: Simple way for web to execute root shell script.1Richard Kettlewell
24 May 25 i`- Re: Simple way for web to execute root shell script.1Rich
24 May 25 +- Re: Simple way for web to execute root shell script.1Andrew Smallshaw
29 May 25 +* Re: Simple way for web to execute root shell script.2Michael Schwingen
29 May 25 i`- Re: Simple way for web to execute root shell script.1The Natural Philosopher
4 Jun 25 `- Re: Simple way for web to execute root shell script.1Chris Narkiewicz

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal