newmail script

Advanced feature discussion, beta programs and unsupported "Labs" features.
2 posts Page 1 of 1
by nhdesign » Tue Mar 13, 2018 6:16 am
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
#
#
by nhdesign » Wed Mar 14, 2018 9:12 am
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
#
#
2 posts Page 1 of 1

Who is online

In total there are 26 users online :: 0 registered, 0 hidden and 26 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 26 guests