Article 5NKWV Why does this bash script work if called from the command line but not when called from a php script run by a webpage?

Why does this bash script work if called from the command line but not when called from a php script run by a webpage?

by
KenHorse
from LinuxQuestions.org on (#5NKWV)
More precisely, the variables in the script are not returned to the calling php script

First the call from the php script:

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 "&nbsp;${FTEMP}&deg;F, ${CTEMP}&deg;C </span>&nbsp; @ `date +%H:%M`&nbsp;"If called from command line:

root@myhost:~# /usr/local/sbin/supermon/get_temp
CPU: <span style="background-color: palegreen;">&nbsp;88&deg;F, 31.6&deg;C </span>&nbsp; @ 08:07&nbsp;

root@myhost:~#

The attachment shows what is displayed in browser:

And yes, both scripts are executable by the world
Attached Thumbnailsattachment.php?attachmentid=36993&stc=1& latest?d=yIl2AUoC8zA latest?i=PXZUZZH78sk:lGxdd_maHI8:F7zBnMy latest?i=PXZUZZH78sk:lGxdd_maHI8:V_sGLiP latest?d=qj6IDK7rITs latest?i=PXZUZZH78sk:lGxdd_maHI8:gIN9vFwPXZUZZH78sk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments