#! /Bin/bash
# User Defined variables
# H, M, s system time
# Rhflag 0 = that day, 1 = tomorrow, 2 = the next day...
# Message sending when strusage threshold is reached
# Timeoffset the time when the user logs in (Time: minute: second)
# Oh, OM, OS time, minute, second (Case 1)/input value (Case 2) listed from timeoffset)
# RH, RM, RS calculation result time, minute, second
# Offset: the value of-h,-M, and-s taken by the user
# System Variables
#$ # Metric data volume
#$0 shell script producer name
#$1 first metric
#$2 second Metric
H = 'date + % H'
M = 'date + % m'
S = 'date + % s'
Rhflag = 0
Strusage = "Usage:/N $0 hh: mm: SS/NOR/N $0 [-H |-M |-S] Number/N"
Case "$ #" in
1)
Timeoffset = $1
Oh = 'echo $ timeoffset | awk-F': ''{print $1 }''
Om = 'echo $ timeoffset | awk-F': ''{print $2 }''
OS = 'echo $ timeoffset | awk-F': ''{print $3 }''
Rs = 'expr $ S + $ OS'
If [$ RS-GT 59]; then
(RS-= 60 ))
Om = 'expr $ om + 1'
Fi
Rm = 'expr $ m + $ om'
If [$ Rm-GT 59]; then
(RM-= 60 ))
Oh = 'expr $ OH + 1'
Fi
RH = 'expr $ H + $ oh'
If [$ rh-GT 24]; then
(Rhflag = Rh/24 ))
(RH % = 24 ))
Fi
;;
2)
Offset = $2
If [$1 = "-h"]; then
RH = 'expr $ H + $ offset'
Rm = $ m
Rs = $ s
If [$ rh-GT 24]; then
(Rhflag = Rh/24 ))
(RH % = 24 ))
Fi
Elif [$1 = "-M"]; then
RH = $ H
Rm = 'expr $ m + $ offset'
Rs = $ s
If [$ Rm-GT 59]; then
(Oh = RM/60 ))
(RM % = 60 ))
RH = 'expr $ H + $ oh'
If [$ rh-GT 24]; then
(Rhflag = Rh/24 ))
(RH % = 24 ))
Fi
Fi
Elif [$1 = "-s"]; then
RH = $ H
Rm = $ m
Rs = 'expr $ S + $ offset'
If [$ RS-GT 59]; then
(OM = RS/60 ))
(RS % = 60 ))
(RM + = om ))
If [$ Rm-GT 59]; then
(Oh = RM/60 ))
(RM % = 60 ))
(Rh + = OH ))
If [$ rh-GT 24]; then
(Rhflag = Rh/24 ))
(RH % = 24 ))
Fi
Fi
Fi
Else
Printf $ strusage
Exit 1
Fi
;;
*)
Printf $ strusage
Exit 1
;;
Esac
If [$ rh-EQ 24]; then
RH = 0
Rhflag = 1
Fi
Echo "$ H: $ M: $ S"
Echo "$ rhflag $ RH: $ RM: $ Rs"