I'm getting an error ((standard_in) 1: syntax error) trying to run the below code in a bash script. Could someone please point me in the correct direction?
if [[ $(bc <<< "$p0value > $freezeMax") ]]; then
vP0='<a href="f1.php" class="blink">[Freezer 1: '
vP0=$vP0$p0value
vP0="$vP0 °C]</a>"
tempDIFF=$( bc <<< "$p0value-$freezeMax")
echo "$P0_name is currently at $p0value °C, which is $tempDIFF °C higher than it should be. Please attend to this." >> $emailPATH/email.txt
sendP0=1
elif [[ $(bc <<< "$p0value < $freezeMin") ]]; then
vP0='<a href="f1.php" class="blink">[Freezer 1: '
vP0=$vP0$p0value
vP0="$vP0 °C]</a>"
tempDIFF=$(bc <<< "$freezeMin-$p0value")
echo "$P0_name is currently at $p0value °C, which is $tempDIFF °C lower than it should be. Please attend to this." >> $emailPATH/email.txt
sendP0=1
else
vP0='<a href="f1.php" class="steady">[Freezer 1: '
vP0=$vP0$p0value
vP0="$vP0 °C]</a>"
sendP0=0
fi
FYI: the variables contain float numbers so I need to use bc to do the calculations.
Extra Info:
I'm running this on a Raspberry Pi 2 running Raspbian Jessie.
The shebang is #! /bin/bash
bcbefore actually doing so. For example:printf 'freezeMin=%s\n' "$freezeMin". This way you will detect whether a variable is empty or has an unexpected value. The script, as it stands above, is also incomplete as it is missing the initialization of most variables. This makes it very difficult to test run for us.source /usr/local/bin/temp/settings.confand the permissions on that file are 777 for the time being.