Petit Probleme Script

bichoking Messages postés 89 Statut Membre -  
bichoking Messages postés 89 Statut Membre -
Bonjour,
J'ai besoin de votre aide, car en faite j'ai écrit un script, mais ce scripte ne s'effectue pas correctement.
Le voici :

#!/bin/bash
system=`hostname`
for line in `df -aPh | grep "^/" | grep \% | sort | awk '{print$6"-"$5"-"$4}'`; do
percent=`echo "$line" | awk -F - '{print$2}' | cut -d % -f 1`
partition=`echo "$line" | awk -F - '{print$1}' | cut -d % -f 1`

limit=80

if [ $partition == '/' ] && [ $percent > $limit ] ; then
echo "Votre partition $partition atteint $percent %" > Logs/Partition1.txt
fi

if [ $partition == '/dev/shm' ] && [ $percent > $limit ] ; then
echo "Votre partition $partition atteint $percent %" > Logs/Partition2.txt
fi

if [ $partition == '/home' ] && [ $percent > $limit ] ; then
echo "Votre partition $partition atteint $percent %" > Logs/Partition3.txt
fi

if [ $partition == '/center' ] && [ $percent > $limit ] ; then
echo "Votre partition $partition atteint $percent %" > Logs/Partition4.txt

fi
done

Le probleme est que meme si le pourcentage de la partition est inférieur a la limite, le fichier Partiiton2, ou 3, ou 4 , sécrit quand même. Je ne sais pas ou se trouve mon erreur.
Merci de votre aide.
Configuration: Windows XP
Firefox 2.0.0.16

2 réponses

  1. jj
     
    Il me semble que c'est plus simple

    Admettons que la limite soit 80 %
    une commande comme ca donne déja un résultat probant
    df -k | awk ' NR>1 && $5*1>80 {print $1}'

    Ensuite il suffit de passer la limite en argument à awk avec

    limite=80
    df -k | awk -v lim=$limite ' NR>1 && $5*1>lim {print $1}'
    1
  2. bichoking Messages postés 89 Statut Membre 13
     
    Hey !
    Merci jj sa marche
    0