Donald E. Hammond
1998-01-05 00:19:28 UTC
I want to forward copies of selected messages to my work address,
and one of the tests is the time it is received. I am having
trouble with the assignment and testing of DAY and HOUR variables.
I'm testing this at home with procmail v3.10 1994/10/31, but it will
be run at my account at the ISP using procmail v3.11pre5 1997/04/03.
(I know these are old. I'm working on getting them updated.) What
I have so far is getting delivered properly, but the logs indicate
it's not without some problems. This is what I have in the rc file
used to test this stuff at home:
PATH=/home/deh/bin:/usr/local/bin:/bin:/usr/bin
DEFAULT=/var/spool/mail/deh
PMDIR=$HOME/Mail
INCLUDERC=$PMDIR/.procmail_testrc
LOGFILE=$PMDIR/procmaillog
LOGABSTRACT=all
VERBOSE=yes #change to yes for debugging
DAY=`date +%a`
HOUR=`date +%H`
NL="
"
:0
* ? test $HOUR -gt 12
{
LOG=" $HOUR > 12 $NL"
:0:
$PMDIR/12+
}
:0
* ? test $HOUR -le 12
{
LOG=" $HOUR =< 12 $NL"
:0:
$PMDIR/12-
}
A test message sent around 5:20p ends up with the following log
entries. The assignment to $DAY and $HOUR fail the first time
through, followed by a fail of 'test' because the variables
don't have a value. Then it tries it all again, and everything
seems to work ok.
procmail: Assigning "LOGABSTRACT=all"
procmail: Assigning "VERBOSE=yes"
procmail: Executing "date,+%a"
date: write error: Bad file number
procmail: Assigning "DAY="
procmail: Executing "date,+%H"
date: write error: Bad file number
procmail: Assigning "HOUR="
procmail: Assigning "NL=
"
procmail: Executing " test $HOUR -gt 12"
/bin/bash: test: -gt: unary operator expected
procmail: Program failure (1) of " test $HOUR -gt 12"
procmail: No match on " test $HOUR -gt 12"
procmail: Executing " test $HOUR -le 12"
/bin/bash: test: -le: unary operator expected
procmail: Program failure (1) of " test $HOUR -le 12"
procmail: No match on " test $HOUR -le 12"
procmail: Assigning "LOGFILE=/home/deh/Mail/procmaillog"
procmail: Opening "/home/deh/Mail/procmaillog"
procmail: Assigning "LOGABSTRACT=all"
procmail: Assigning "VERBOSE=yes"
procmail: Executing "date,+%a"
procmail: Assigning "DAY=Sun"
procmail: Executing "date,+%H"
procmail: Assigning "HOUR=17"
procmail: Assigning "NL=
"
procmail: Executing " test $HOUR -gt 12"
procmail: Match on " test $HOUR -gt 12"
procmail: Assigning "LOG= 17 > 12
"
17 > 12
procmail: Locking "/home/deh/Mail/12+.lock"
procmail: Assigning "LASTFOLDER=/home/deh/Mail/12+"
procmail: Opening "/home/deh/Mail/12+"
procmail: [7609] Sun Jan 4 17:17:16 1998
procmail: Unlocking "/home/deh/Mail/12+.lock"
From deh Sun Jan 4 17:17:14 1998
Subject: procmail test 9
Folder: /home/deh/Mail/12+ 361
procmail: Notified comsat: "***@1356:/home/deh/Mail/12+"
When this is working ok, I won't need both the -gt and -le tests.
This is just for testing purposes here. What obvious problem
am I missing this time?
Thanks.
- Don
and one of the tests is the time it is received. I am having
trouble with the assignment and testing of DAY and HOUR variables.
I'm testing this at home with procmail v3.10 1994/10/31, but it will
be run at my account at the ISP using procmail v3.11pre5 1997/04/03.
(I know these are old. I'm working on getting them updated.) What
I have so far is getting delivered properly, but the logs indicate
it's not without some problems. This is what I have in the rc file
used to test this stuff at home:
PATH=/home/deh/bin:/usr/local/bin:/bin:/usr/bin
DEFAULT=/var/spool/mail/deh
PMDIR=$HOME/Mail
INCLUDERC=$PMDIR/.procmail_testrc
LOGFILE=$PMDIR/procmaillog
LOGABSTRACT=all
VERBOSE=yes #change to yes for debugging
DAY=`date +%a`
HOUR=`date +%H`
NL="
"
:0
* ? test $HOUR -gt 12
{
LOG=" $HOUR > 12 $NL"
:0:
$PMDIR/12+
}
:0
* ? test $HOUR -le 12
{
LOG=" $HOUR =< 12 $NL"
:0:
$PMDIR/12-
}
A test message sent around 5:20p ends up with the following log
entries. The assignment to $DAY and $HOUR fail the first time
through, followed by a fail of 'test' because the variables
don't have a value. Then it tries it all again, and everything
seems to work ok.
procmail: Assigning "LOGABSTRACT=all"
procmail: Assigning "VERBOSE=yes"
procmail: Executing "date,+%a"
date: write error: Bad file number
procmail: Assigning "DAY="
procmail: Executing "date,+%H"
date: write error: Bad file number
procmail: Assigning "HOUR="
procmail: Assigning "NL=
"
procmail: Executing " test $HOUR -gt 12"
/bin/bash: test: -gt: unary operator expected
procmail: Program failure (1) of " test $HOUR -gt 12"
procmail: No match on " test $HOUR -gt 12"
procmail: Executing " test $HOUR -le 12"
/bin/bash: test: -le: unary operator expected
procmail: Program failure (1) of " test $HOUR -le 12"
procmail: No match on " test $HOUR -le 12"
procmail: Assigning "LOGFILE=/home/deh/Mail/procmaillog"
procmail: Opening "/home/deh/Mail/procmaillog"
procmail: Assigning "LOGABSTRACT=all"
procmail: Assigning "VERBOSE=yes"
procmail: Executing "date,+%a"
procmail: Assigning "DAY=Sun"
procmail: Executing "date,+%H"
procmail: Assigning "HOUR=17"
procmail: Assigning "NL=
"
procmail: Executing " test $HOUR -gt 12"
procmail: Match on " test $HOUR -gt 12"
procmail: Assigning "LOG= 17 > 12
"
17 > 12
procmail: Locking "/home/deh/Mail/12+.lock"
procmail: Assigning "LASTFOLDER=/home/deh/Mail/12+"
procmail: Opening "/home/deh/Mail/12+"
procmail: [7609] Sun Jan 4 17:17:16 1998
procmail: Unlocking "/home/deh/Mail/12+.lock"
From deh Sun Jan 4 17:17:14 1998
Subject: procmail test 9
Folder: /home/deh/Mail/12+ 361
procmail: Notified comsat: "***@1356:/home/deh/Mail/12+"
When this is working ok, I won't need both the -gt and -le tests.
This is just for testing purposes here. What obvious problem
am I missing this time?
Thanks.
- Don