Page 1 of 1

newmail script

Posted: Tue Mar 13, 2018 6:16 am
by nhdesign
Good Morning,

Since moving to imap the script newmail-maildir written by someone a long time ago no longer works.
I have procmail touch $HOME/.mail-semaphore with every mail that arrives.
Then have this script run every few minutes by crontab and print an alert to the screen.
It does not work because I don't know what I am doing. Hopefully you see the intent and can fix it.
It appears the time chack of the two files is not happening and the script dies.
The cat command works fine on the command line.
I tried comp.unix.shell, no help there.

Thanks,
Vic

#!/bin/sh
#!/bin/bash
# newmail-semaphore
# 20180305

### check if .mail-semaphore has a later timestamp than .mail-semaphore-flag

# if [[ "$HOME/.mail-semaphore-flag" -lt "$HOME/.mail-semaphore" ]]
if [[ "$HOME/.mail-semaphore-flag" -nt "$HOME/.mail-semaphore" ]]

then

### printed $HOME/.mail-semaphore to the screen.

cat $HOME/.mail-semaphore | /usr/local/bin/tellme.pl

touch -r $HOME/.mail-semaphore $HOME/.mail-semaphore-flag

fi

### from my .procmailrc
#
# SEMAPHORE=$HOME/.mail-semaphore
# :0c
# *
# | head -1 > $SEMAPHORE
#
#

Re: newmail script

Posted: Wed Mar 14, 2018 9:12 am
by nhdesign
Works well.
enter in your crontab
add last few lines to your .procmailrc
make a .linefeed, or eliminate it from the script.

#!/bin/sh
# newmail-semaphore
# 20180314

### Script to compare time stamp on two files and if different report to terminals.

### check if .mail-semaphore has a later timestamp than .mail-semaphore-flag

if [[ "$HOME/.mail-semaphore" -nt "$HOME/.mail-semaphore-flag" ]]

then

### printed $HOME/.mail-semaphore to the screen.

cat $HOME/.mail-semaphore | /usr/local/bin/tellme.pl

touch -r $HOME/.mail-semaphore $HOME/.mail-semaphore-flag

fi

### from my .procmailrc --------------------------------------------------------
#
# SEMAPHORE=$HOME/.mail-semaphore
# :0c
# *
# | cat $HOME/.linefeed > $SEMAPHORE ; cat $HOME/.linefeed >> $SEMAPHORE ; head -1 >> $SEMAPHORE ; cat $HOME/.linefeed >> $SEMAPHORE
#
#