So I've been making some progress on my question and I was actually playing around with the date command before I saw your response. On mac OS I have been using the command:
systemsetup -gettime which returns Time: HH:MM:SS
so I've been trying to figure out how to strip Time: and assign hours=HH minutes=MM seconds=SS. I could then:
sh script.sh 300 1 10
- get current system time with systemsetup -gettime
- strip Time: and convert the system time to seconds
- initialize cycle count to 1 and
- while count less than 10 (passed in from command line as $3) do
- wait for 300 seconds (passed in from command line as $1)
- add the increment 1 (passed in from command line as $2) to system time converted to seconds as new_systemtime
- convert new_systemtime back to HH:MM:SS format
- reset system time to new_systemtime by systemsetup -settime $new_systemtime
- increment cycle_count by 1
I was able to use awk -F: to print each number independently. It's ugly, but:
systemsetp -gettime ; a=$(systemsetup -gettime) ; echo $a | awk -F: '{print $2":"$3":"$4}'
Time: 22:32:59
22:32:59
but then I got stuck at how to shove $2 $3 and $4 into the variables hours, minutes, and seconds instead of printing them.
Anyhow, any tips would be greatly appreciated on how to go about each of those steps, or if I'm just going about it all the wrong way, that'd be good to know too