Results 1 to 5 of 5
Hello all,
I am facing one basic problem i don`t know why ? here is my problem
I written script like as follows
while [ 1 ]
do
sone=17:00
send=19:00
...
- 10-18-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 45
How to check my conditions..!!!
Hello all,
I am facing one basic problem i don`t know why ? here is my problem
I written script like as follows
while [ 1 ]
do
sone=17:00
send=19:00
check=`uptime | cut -c2,3,4,5,6`
# check will give the current time
here i want to check the " is $check is in between the $sone and $send"
done
how ?
please help ...!!!
- 10-18-2008 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
I would change the variables into numbers by removing the colons.
EDIT: I would use the date command to get the current time.Code:#!/bin/bash -vx sone=1700 send=1900 check="`date +%H%M`" if [ "$check" -ge "$sone" -a "$check" -le "$send" ] then echo "Yes" fi
- 10-18-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 45
check
thanks
what is -vx in the starting ?
and I need to check for 24 hour how i need to write the conditions
I mean i am going to declare 24 strings like as follows
sone=0000
oneend= 0200
stwo=0200
twoend=0400
sthree=0400
threeend=0600
like this it will go for up to 12x2 = 24
#ctime current time
how i need to check the ctime is in between sone and oneend next stwo and twoend next sthree and threeend upto 12
can i use if or what ?
please help ...!!!
- 10-18-2008 #4Linux User
- Join Date
- Jun 2007
- Posts
- 318
-vx means show the commands as they are being executed. Helps in debugging.
If you have to break up the time of day into 2 hour increments then a little simple math would do it.
0000 thru 0159 will return 1Code:#!/bin/bash -vx ctime="`date +%H`" nmbr=$(( ($ctime / 2) + 1))
0200 thru 0259 will return 2
.
.
.
2200 thru 2359 with return 12
- 10-22-2008 #5Just Joined!
- Join Date
- Feb 2008
- Posts
- 45
check my condition
thanks for the solution


Reply With Quote