Your script:
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
echo "Equipo => $(hostname)"
echo "$(date)"
echo "------------------------------"
echo "Temp.CPU => $((cpu/1000))'Cº"
echo "Temp.GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "------------------------------"
echo "CPU"
echo "$(vcgencmd measure_clock arm)Hz"
echo "$(vcgencmd measure_volts core)"
echo "Mem. del Sistema $(vcgencmd get_mem arm)"
echo "Mem. de la $(vcgencmd get_mem gpu)"
echo "------------------------------"
echo "Consumo de memoria"
echo "$(egrep --color 'Mem|Cache|Swap' /proc/meminfo)"
OK
If your raspberry does not have an http server with php setup, run these commands:
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php -y
full howto: https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
Then create a php file - getTemp.php, in your /var/www/html directory:
<?php
$output = shell_exec("sudo /home/<user>/temp.sh 2>&1"); // use correct full path to script
echo $output;
?>
Then test this by running the php file from a remote computer:
http://<raspberryIP>/getTemp.php
See what happens - there may be some permissions issues to resolve....
Your script requires some elevated privileges, so you may need to make apache user www-data a sudoer:
sudo visudo
(pick nano if offered)
add to the bottom of the file:
www-data ALL=(ALL) NOPASSWD: ALL
In your app, you can either use a webviewer to see the output, or web component to get the return value in .GotText
Nice script ![]()
Here it is working for me (I edited the script to English)
