[#!/fr] Détermination administateur(s) OSX10.4

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Yves Petronin
Date:  
À: script_shell_fr
Sujet: [#!/fr] Détermination administateur(s) OSX10.4
Je recherche à obtenir le nom d'un administrateur ayant une session
ouverte, et s'il n'y en a pas, le nom d'un administrateur de la machine.
J'ai trouvé ce qui suit, mais je trouve que c'est assez compliqué et
sans doute très perfectible (je suis débutant) Quelqu'un a t'-il une
idée pour faire plus simple ou/et mieux?. Merci

#SCRIPT
#!/bin/sh

#Determination of administrator short name

USER_CONNECTED=`who -m | awk '{print ($1)}'` # user connected
USERS=`dscl . -list /Users NFSHomeDirectory | awk '/[[:space:]]\/Users 
\//{print $1}'`
for i in ${USERS}
do
ADMIN=`id -Gn  ${i}  | grep admin | awk '{print ($1)}'` # User with  
administrator privileges
if   [ "$ADMIN" != "" ] && [ "$ADMIN" == "$USER_CONNECTED" ]     
then
administrator=$USER_CONNECTED #Testing is this admin is connected. If  
yes , select.
break
else
if  [ "$ADMIN" != "" ]
then
administrator=${ADMIN} # Name of administrator selected if no admin  
connected.
fi
fi
done
exit 0
#SCRIPT



_______________________________________________
archives :
http://listes.patpro.net/list/sshfr.fr.html
http://listes.patpro.net/mailman/listinfo/script_shell_fr