#!/bin/bash # The user's name is extracted from the # monitored directory's path ($@) # and is passed as argument $1 from # incrontab. # Delete the user's incrontab file rm /var/spool/incron/`echo $1|cut -d / -f 3` # Examine each item in the user's directory for i in $1/* do # ... Build an incrontab rule for # each directory (ignore files). if [ -d $i ] then echo "$i IN_CREATE send_mail.sh address@admin.com `cat $1/.emailaddress`" '$# $@' >> /var/spool/incron/`echo $1|cut -d / -f 3` fi done