I need to run a command when something is entered in BASH with a certain time-frame, and if it's not that time run another command. Here's what I've got so far, but it doesn't appear to be working..
if ! [[ $FLATTIME -gt 1130 ]] ; then
mysql --host=192.168.0.100 --user=myself --password=mypass thedb << EOF
INSERT INTO $STAFFID values ('','$STAFFID','$THETIME','','$THEDATE','$DAYOFWEEK');
mysql --host=192.168.1.92 --user=myself --password=mypass thedb << EOF
UPDATE $STAFFID SET Out_Time='$THETIME' WHERE date='$THEDATE';
In this case, you just need to look at the hour. Also, bash has syntax to specify the radix of a number, so you don't have to worry about 08 and 09 being invalid octal numbers:
H=$(date +%H) if (( 8 <= 10#$H && 10#$H < 13 )); then echo between 8AM and 1PM elif (( 13 <= 10#$H && 10#$H < 23 )); then echo between 1PM and 11PM else echo go to bed fi
"10#$H" is the contents of the variable, in base 10.