#!/bin/sh # # Script permettant de monitorer une action particulière. # Prédéfinitions ACTION="" SIZEMAX=1 if [ "$1" = "-p" ]; then ACTION="lpq" elif [ "$1" = "-f" ]; then ACTION="ls -l $2" if [ "$3" != "" ]; then SIZEMAX=$3 fi elif [ "$1" = "-h" ]; then echo "monitor -p : surveille l'impression" echo "monitor -f fichier [taille] : surveille la taille d'un fichier" echo "monitor action : surveille l'action passé en paramètre" exit fi # Recréation de la ligne de commande à exécuter if [ "$ACTION" = "" ]; then while [ "$1" != "" ]; do ACTION="$ACTION $1" shift done; fi # Lancement du monitoring if [ "$ACTION" != "" ]; then echo "Monitoring : [$ACTION]" sleep 2 CURSIZE=0 while [ $CURSIZE != $SIZEMAX ]; do clear $ACTION if [ $SIZEMAX != 1 ]; then CURSIZE=`$ACTION | awk '{print $5}'` fi sleep 1; done fi