1 Attachment(s)
Why does this bash script work if called from the command line but not when called fr
More precisely, the variables in the script are not returned to the calling php script. Both scripts are executable by the world
First the call:
Code:
$CPUTemp = exec("/usr/local/sbin/supermon/get_temp");
print " [ $CPUTemp]";
Now the bash script:
Code:
echo -n "CPU: "
CTEMP=$(/opt/vc/bin/vcgencmd measure_temp)
CTEMP=${CTEMP:5}
SAVE=$IFS; IFS="'"; set -- $CTEMP; IFS=$SAVE
CTEMP=$1; FTEMP=$(echo 9 '*' $CTEMP / 5 + 32 | /usr/bin/bc)
if [ "$FTEMP" -le "120" ]; then
echo -en "<span style=\"background-color: palegreen;\">"
elif [ "$FTEMP" -le "150" ]; then
echo -en "<span style=\"background-color: yellow;\">"
else
echo -en "<span style=\"font-weight: bold; color: yellow; background-color: red;\">"
fi
echo -en " ${FTEMP}°F, ${CTEMP}°C </span> @ `date +%H:%M` "
Attachment 3681Attachment 3681
If called from command line:
root@myhost:~# /usr/local/sbin/supermon/get_temp
CPU: <span style="background-color: palegreen;"> 88°F, 31.6°C </span> @ 08:07
root@myhost:~#
The attachment shows what is displayed in browser