01-08-2024, 11:59 PM
(01-08-2024, 10:31 PM)Nutul Wrote:(01-08-2024, 10:17 PM)Wallyboy Wrote:(01-08-2024, 09:46 PM)Nutul Wrote:(01-08-2024, 09:18 PM)Wallyboy Wrote:(01-07-2024, 09:23 PM)Nutul Wrote: Just prepend sudo to the command; although that rings a bell... about the "echo" thing...
Maybe it's better you include the three commands in a shell script, and then invoke the script with:
sudo ./yourscript.sh
although I am not sure if that would wait for the password... maybe making "root" the script owner, and then setting its sticky flag would have better chances of running.
I'm having no luck with the sh script. I would rather use a python script but I cannot figure out how to do the moodeutl test as described above.. I have attached the code snippet below as suggested for the sh script. Anyone know how to implement this in python?
Code:until test $(moodeutl -q "select value from cfg_system where param='wrkready'") = "1"; do
Not in this very moment; but it is a program call, something in the lines of sysCall("moodeutl -q ... ") = "1", or exec(" ... ")...
wait a sec:
import subprocess
subprocess.run(["ls", "-l"])
1st element in the array is the program/command, and further ones are the arguments to such program.
I tried that previously and the query does not seem to be recognized using : subprocess.Popen (["/usr/local/bin/moodeutl", " -q","select value from cfg_system where param='wrkready'"])
Code:sudo nano boot_indicator.py
pi@pi:/usr/local/bin $ sudo ./boot_indicator.py
Usage: moodeutl [OPTION]
Moode utility programs
With no OPTION print the help text and exit.
-a Print features availability
-A [add|rm N] Update features availability
-d Dump session file (requires sudo)
-D [var name] Delete session variable (requires sudo)
-e [filename] Export settings to [filename] or ~/moodecfg-<timestamp>.ini (requires sudo)
-i Import settings from /boot/moodecfg.ini (requires sudo)
-f Print supported audio formats
-F Print full alsacap info
-l Print moode log
-m Run system monitor
-s Print system info
-c Detect CIFS (SMB) hosts
-C Detect CIFS (SMB) shares [host or ip address]
-N Detect NFS hosts
-M Detect MPD hosts
-o List audio overlays
-q Query sql database
-r Restart servers
-R Restart renderer [--bluetooth | --airplay | --spotify | --squeezelite | --roonbridge]
-t Print last 10 lines of moode log and wait
-u Check radio station urls for playability
-U Check station urls, list only unplayable
--hwparams Print ALSA hardware params
--btreset Reset Bluetooth to off
--mpdlog Print MPD log
--updlog Print in-place update log
--mountmonlog Print mount monitor log
--autocfglog Print auto config update log
--sleepint Print daemon sleep intervals
--mooderel Print moOde release
--pirev Print Pi revision
--osinfo Print OS info
--version Print program version
--help Print this help text
pi@pi:/usr/local/bin $
try removing the spave before -q, so that is reads "-q", and not " -q"
Thank you. That worked. It returns a "1" to the console . Could you suggest how I would code testing the result within the python script.