#scipt temporaire date="$(date +%Y-%m-%d)" scandir="/home/oscar/scan-souris/" ecole="/home/oscar/ECOLE/" nb=0 #vérification fichier double verif () { if [ $1 = "BACKUP" ]; then while true; do if [ -e "$scandir${1}/scan_${date}_$nb" ];then ((nb=$nb+1)) else break; fi done # /!\ ceci n'est pas un debug echo ${scandir}${1}/scan_${date}_$nb else while true; do if [ -e "$ecole${1}/scan_${date}_$nb" ];then ((nb=$nb+1)) else break; fi done # /!\ ceci n'est pas un debug echo $ecole${1}/scan_${date}_$nb fi } #scan nouveau fichier scan () { while true; do sleep 2 #ls que les noms puis for mais avec un while ls -1 /home/oscar/scan-souris | while read -r file; do echo $? nb=0 echo $file #ne prends pas en compte le dossier backup if [ $file != "BACKUP" ]; then no_bool=0 #liste les process de l'utilisateur puis ne garde que 2 colonne d'information relative à la commande ps -u | tr -s " " | cut -d " " -f 11,12 | while read -r process; done case $process in *"maths"*) path=$( verif MATHS ) cp $scandir$file $path pathb=$( verif BACKUP ) mv $scandir$file $pathb echo "fichier transvasé dans MATHS" no_bool=1 ;; *"français"*) path=$( verif FRANCAIS ) cp $scandir$file $path pathb=$( verif BACKUP ) mv $scandir$file $pathb echo "fichier transvasé dans FRANCAIS" no_bool=1 ;; *"poésie"*) path=$( verif POESIE ) cp $scandir$file $path pathb=$( verif BACKUP ) mv $scandir$file $pathb echo "fichier transvasé dans POESIE" no_bool=1 ;; *"histoire"*) path=$( verif HISTOIRE ) cp $scandir$file $path pathb=$( verif BACKUP ) mv $scandir$file $pathb echo "fichier transvasé dans HISTOIRE" no_bool=1 ;; *"ergothérapeute"*) path=$( verif ERGOTHÉRAPEUTE ) cp $scandir$file $path pathb=$( verif BACKUP ) mv $scandir$file $pathb echo "fichier transvasé dans ERGOTHERAPEUTE" no_bool=1 ;; esac done if [ no_bool == 0 ]; then path=$( verif SCAN ) cp $scandir$file $path pathb=$( verif BACKUP ) mv $scandir$file $pathb echo "aucune matière lancée, fichier tranvasé dans SCAN" fi fi done #echo "sortie while" done } scan