|
小弟今天做了一个定时关机的shell,涉及到时间判定的问题,没有找到and or之类的逻辑语句,所用了多重if嵌套,但是语句通不过检测,请各位大虾帮忙看看啊!
shell如下:
#!/bin/sh
WEEK=`date +%H`
MINTE=`date +%M`
#the judge for hour
if $WEEK -gt 7
then
echo "the time passed ,wait next time,halting ..."
else
if $WEEK -lt 6
then
echo "too early to start,have a good rest,system is halting ..."
if $MINTE -gt 30
then
echo "the time is too late ,wait for the next time "
fi
fi
fi
if $WEEK -lt 11
then
echo "the time is not come,wait ...,system is halted..."
else
if $WEEK -gt 13
then
echo "the time is lost ,the system is halting..."
fi
if $MINTE -lt 30
then
echo "the time is too ealier,wait a moment"
fi
fi
if $WEEK -lt 17
then
echo "the time is not come,wait ...,system is halted..."
if $MINTE -lt 30
then
echo "the is is too early,wait a moment..."
fi
else
if $WEEK -gt 18
then
echo "the time is over ,waiting for the system halting..."
if $NINTE -gt 30
then
echo "the time is too late ,waiting for shutdwon..."
fi
fi
fi
if $WEEK -lt 21
then
echo "the time si not come,wait ...,system is halted..."
else
if $WEEK -lt 23
then
echo "the time is ower ,waiting for the system halting..."
fi
fi |
|