1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #!/bin/bash
if ( test $# -eq 0 )
then
echo 'Erreur sy'
else
ps hU $1 -o state,comm > tempfile
number=$(wc -l < tempfile)
i=1
while [ $i -le $number ]
do
commande=$( tail -$i tempfile | head -1 | cut -d" " -f2 )
etat=$(tail -$i tempfile | head -1 | cut -d" " -f1 )
let i=i+1
echo -n " $commande :"
case $etat
in
D) echo "endormi => ininterptuble" ;;
S) echo "endormi" ;;
R) echo "en cours" ;;
T) echo "stop" ;;
Z) echo "zombie" ;;
*) echo "inconnu" ;;
esac
done
rm tempfile
fi |
Partager