Aquí os dejo este script, a mí me sirve para recoger automáticamente el correo de todas mis cuentas y notificarme de su llegada. Con la notificación, me abre directamente mutt en una terminal.
El script lo meto en un crontab del usuario y también creo un logrotate para los logs que genera. Si a alguien le interesa le paso el resto.
El script en cuestión es éste:
Código:
#!/bin/sh
# With this configuration, it is necessary to create a
# directory /var/run/cogecorreo.$USER with the current user
# as owner, as well as a /var/log/cogecorreo.$USER.log one.
#
# i.e. (as root):
# mkdir /var/run/cogecorreo.$USER
# touch /var/log/cogecorreo.$USER.log
# chown $USER /var/run/cogecorreo.$USER /var/log/cogecorreo.$USER.log
#
logfile="/var/log/cogecorreo.$USER.log"
pidfile="/var/run/cogecorreo.$USER/cogecorreo.pid"
maildir="/home/$USER/Maildir"
mboxes="$maildir/mailboxes"
if [[ $1 == '-d' ]]; then
debug=1
fi
function marca {
date +%d-%m-%Y--%H:%M:%S
}
function sep {
echo '-------------------------------------------------------------------------------'
}
function old_open {
test -f $pidfile || return 1
}
function notify {
echo $$ > $pidfile
if [[ `find $mboxes/ -type d -name new -exec ls {} \; ; ls $maildir/new` != '' ]]; then
kdialog --display :0 --msgbox 'Hay correo nuevo' && xterm -display :0 -fb black -fa 'Andale Mono' -fg orange -fs 13 -e 'mutt -y'
fi
rm -f $pidfile
}
function main {
sep
marca
if [[ -z $debug ]]; then
mpop -n --tls-certcheck=off
fetchmail
fi
old_open || notify | tee -a $logfile
}
exec 2>&1
(($debug)) && set -x
main
Asimismo, si a alguien interesa el shell scripting puedo comentar el código, que es bantante sencillo.
Salu2
Marcadores