banniere
BLUMAX WebSite
Espace privé
Adresse courriel :
Mot de passe :
Stat
  • 4 inscrits sur le site
  • 0 personne en ligne
  • 38 téléchargements
  • 34 articles
  • 65 réponses dans la FAQ
  • Les 2 derniers inscrits
    - Airwheel
    - PoPo
FAQ -> Liste de question


Comment lancer une commande quand un fichier est déposé dans un répertoire ?

#!/bin/sh

# CONFIGURATION
DIR="/var/www/handibouge.fr/admin/ftp/1/"
EVENTS="close_write"

FIFO="/tmp/inotify2.fifo"

# FUNCTIONS
on_exit() {
kill $INOTIFY_PID
rm $FIFO
exit
}

on_event() {
local date=$1
local time=$2
local file=$3

echo "$date $time Fichier créé: $file"
}

# MAIN
if [ ! -e "$FIFO" ]
then
mkfifo "$FIFO"
fi

inotifywait -m -e "$EVENTS" --timefmt '%Y-%m-%d %H:%M:%S' --format '%T %f' "$DIR" > "$FIFO" &
INOTIFY_PID=$!

trap "on_exit" 2 3 15

while read date time file
do
on_event $date $time $file &
done < "$FIFO"

on_exit


© 2004-2024 blumax.fr