mysql - BASH - If $TIME between 8am and 1pm do.., esle do.. Specifying time variables and if statements in BASH -


i need run command when entered in bash time-frame, , if it's not time run command. here's i've got far, doesn't appear working..

flattime=$(date "+%h%m") flattime=${flattime##0}  if ! [[ $flattime -gt 1130 ]] ; mysql --host=192.168.0.100 --user=myself --password=mypass thedb << eof insert $staffid values ('','$staffid','$thetime','','$thedate','$dayofweek'); eof  else mysql --host=192.168.1.92 --user=myself --password=mypass thedb << eof update $staffid set out_time='$thetime' date='$thedate'; eof fi 

ideally i'd have like: if time between 8am , 1pm first command, if time between 1pm , 11pm second command, else echo "someone's been @ work long". i've tried few variations no luck, seems run first command whatever do..

in case, need @ hour. also, bash has syntax specify radix of number, don't have worry 08 , 09 being invalid octal numbers:

h=$(date +%h) if (( 8 <= 10#$h && 10#$h < 13 ));      echo between 8am , 1pm elif (( 13 <= 10#$h && 10#$h < 23 ));      echo between 1pm , 11pm else     echo go bed fi 

"10#$h" contents of variable, in base 10.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -