Voilà où j'en suis dans mes recherches
if [ $# -lt 2 ]
#there are only two parameters and we need 3.
then
echo "You have to use this command this way : findproc {-o owner|-p ppid|-r running_time| -u minimum_time_used}"
else
case $1 in
#the search depends of the owner
#owner is the first field of ps -f
-[oO]) ps -ef | grep -i $2|awk '{ print $2}';;
#the search depends of the PPID
#PPID is the third field of ps -f
-[pP]) ps -ef | grep -i $2|awk '{ print $2}';;
#the search depends of the running_time
#running time is the seventh field of ps -f
-[rR]) ps -ef | grep -i $2|awk '{ print $2}';;
#the search depends of the minimum time of use
#it depends of the time
-[uU]) ps -ef | grep -i $2|awk '{ print $2}';;
*)echo "You have to use this command this way : findproc {-o owner|-p ppid|-r running_time(xx:xx:xx)| -u minimum_time_used(xx:xx:xx)}";;
esac
fi
en gros, ce qu'il me manque, c'est un "truc" pour filtrer les données envoyées par ps avant le grep ;
javais pensé à awk '{print $1 $2}' mais le problème est que, dans ce cas, $1 et $2 contiennent déjà les paramètres de la commande, me semble-t-il... ?
Poste le Wednesday 17 December 2003 01:05:57