I am working on an audio visual art installation, using a Raspberry Pi with Raspbian Jessie. The audio or video is started after login via a bash script. This script runs fine on its own.
My issue has been with trying to schedule the loop to run only during certain times of the day using an if statement. This has been placed at the beginning on the loop to check the time before a new file would start.
HOUR=$(date +"%H")
echo "The hour is $HOUR"
if [ $HOUR -gt 22 || $HOUR-lt 8 ]
then
sleep 60
continue
fi
I have declared HOUR
as an integer with declare -i HOUR
at the beginning of the script.
The script outputs this error, then continues.
./start_audio.sh: line 49: 13: command not found
I believe the variable is set correctly because $HOUR
[13] is shown in the error. So why is $hour
being interpreted as a command when it has been declared as an integer?
Tried changes like adding quotes or removing spaces, as answers to other questions have suggested.