Jay Lee wrote:
Doc Walker said:
I would like to create a rule that operates between the hours of 8:00 AM
and 5:00 PM local time. In man (7) maildropex, there is reference to
the function 'time', which appears to return the current date/time in
number of seconds since Epoch. What is the function to convert this or
extract the hour?
I've been unable to locate anything in man maildropfilter or maildropex.
Google searches turn up results referring to various Perl modules that
perform this conversion, but is there a simpler way?
HOUR=`date +%H`
will assign the current hour to $HOUR. However, it looks like maildrop
sees $HOUR as a string not an integer so something like:
if (($HOUR >=8) && ($HOUR <= 17))
will not work. I've really been spoiled by PHP's automatic variable type
conversion. You should be able to do something like this though, bit
uglier but it'll work, probably is an easier way I'm just not thinking of:
if (($HOUR eq '08') || ($HOUR eq '09') ||...
SOLVED:
#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# Set environment variables:
CURTIME=`/bin/date +%H%M`
#''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# Check whether within appropriate time window
if ( 0800 <= $CURTIME && $CURTIME <= 1700 )
{
# do something
}
else
{
# do something else
}
Rx