Bonjour,
Script dans le but d’avoir les droits en octal.
Tout commentaire est bienvenu, surtout que les gens peuves l’utiliser.
J’avais posté pour demander comment le faire.
Mais la seule réponse était en Perl
Aux besoin les admin peuve déplacer le script
#!/bin/sh
# l'indentation peut être modifiée par le forum!
#**************************************************************************
# Auteur Panthere noire Date de mise a jours 2008-08-01
# Site de l'auteur www.panthere-noire.com
# Ce programme est un logiciel libre.
# Vous pouvez en redistribuer des copies selon les termes
# de la GNU [ General Public License ]
# <http://www.gnu.org/licenses/gpl.html>.
# Il n’y a AUCUNE GARANTIE dans la mesure autorisée par la loi.
# Dépandance du programme [ls], si une modification
# est faite de celui-ci cela pourrait affecter le fonction. : ls
#**************************************************************************
echo "ls Vertion 0.1"
# Groupe de variable non protégé, risque d'écrasement
# Pour éviter cela, il faudrait les exécuter dans un sous processus
# exemple : fonction (){(code, sous processus)}
URet="SUNull"
GRet="SGNull"
ARet="SGNull"
ALLCalc="SCNull"
textutilisateur1=" Fonction utilisateur. \
Erreur caractère non reconnu ou combinaison non gérée."
textgroup1="Fonction goute. \
Erreur caractère non reconnu ou combinaison non gérée."
textautre1="Fonction autres. \
Erreur caractère non reconnu ou combinaison non gérée."
I=0
I=$(($I+1)) # on saute la premiere ligne
function utilisateur()
{
URet="UNull"
if [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "-" ] ;then
URet="00400"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "" ] ;then
URet="00200"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "x" ] ;then
URet="00100"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "x" ] ;then
URet="00500"
elif [ "$1" = "r" ] && [ "$2" = "w" ] && [ "$3" = "-" ] ;then
URet="00600"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "x" ] ;then
URet="00300"
elif [ "$1" = "r" ] && [ "$2" = "w" ] && [ "$3" = "x" ] ;then
URet="00700"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "S" ] ;then
URet="04000"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "s" ] ;then
URet="04100"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "s" ] ;then
URet="04300"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "S" ] ;then
URet="04400"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "s" ] ;then
URet="04500"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "-" ] ;then
URet="00000"
else
echo "$Textutilisateur" $1 $2 $3
fi
}
function grouputilisateur()
{
Gret="GNull"
if [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "-" ] ;then
GRet="00040"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "" ] ;then
GRet="00020"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "x" ] ;then
GRet="00010"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "x" ] ;then
GRet="00050"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "x" ] ;then
GRet="00030"
elif [ "$1" = "r" ] && [ "$2" = "w" ] && [ "$3" = "x" ] ;then
GRet="00070"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "S" ] ;then
GRet="02000"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "s" ] ;then
GRet="02010"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "s" ] ;then
GRet="02030"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "S" ] ;then
GRet="02040"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "s" ] ;then
GRet="02050"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "-" ] ;then
GRet="00000"
else
echo "$textgroup1. $1 $2 $3"
fi
}
function autreutilisateur()
{
ARet="ANull"
if [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "-" ] ;then
ARet="00004"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "" ] ;then
ARet="00002"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "x" ] ;then
ARet="00001"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "x" ] ;then
ARet="00005"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "x" ] ;then
ARet="00003"
elif [ "$1" = "r" ] && [ "$2" = "w" ] && [ "$3" = "x" ] ;then
ARet="00007"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "T" ] ;then
ARet="01000"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "t" ] ;then
ARet="01001"
elif [ "$1" = "-" ] && [ "$2" = "w" ] && [ "$3" = "t" ] ;then
ARet="01003"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "T" ] ;then
ARet="01004"
elif [ "$1" = "r" ] && [ "$2" = "-" ] && [ "$3" = "t" ] ;then
ARet="01005"
elif [ "$1" = "-" ] && [ "$2" = "-" ] && [ "$3" = "-" ] ;then
ARet="00000"
else
echo "$textautre1 $1 $2 $3"
fi
}
function listing_one_car()
{
V1=`echo $* |cut -d":" -f1`
V2=`echo $* |cut -d":" -f2`
V3=`echo $* |cut -d":" -f3`
V4=`echo $* |cut -d":" -f4`
V5=`echo $* |cut -d":" -f5`
V6=`echo $* |cut -d":" -f6`
V7=`echo $* |cut -d":" -f7`
V8=`echo $* |cut -d":" -f8`
V9=`echo $* |cut -d":" -f9`
V10=`echo $* |cut -d":" -f10`
utilisateur "$V2" "$V3" "$V4"
grouputilisateur "$V5" "$V6" "$V7"
autreutilisateur "$V8" "$V9" "$V10"
ALLCalc=`echo "$URet + $GRet + $ARet" |bc`
}
function main ()
{
ls -Al |while read ligne ;do
I=$(($I+1))
if [ "2" != "$I" ] ;then
R1=`echo $ligne |cut -d" " -f1|cut -c1`
U1=`echo $ligne |cut -d" " -f1|cut -c2`
U2=`echo $ligne |cut -d" " -f1|cut -c3`
U3=`echo $ligne |cut -d" " -f1|cut -c4`
G1=`echo $ligne |cut -d" " -f1|cut -c5`
G2=`echo $ligne |cut -d" " -f1|cut -c6`
G3=`echo $ligne |cut -d" " -f1|cut -c7`
A1=`echo $ligne |cut -d" " -f1|cut -c8`
A2=`echo $ligne |cut -d" " -f1|cut -c9`
A3=`echo $ligne |cut -d" " -f1|cut -c10`
listing_one_car "$R1:$U1:$U2:$U3:$G1:$G2:$G3:$A1:$A2:$A3"
echo "$ALLCalc" "$ligne"
fi
done
}
main
exit 0
placer le dans le répertoire /user/bin/le_nom_que_vous_voulez
et exécuter le via son nom comme d’habitude
Note: c’est lent, c’ est normal c est pas du #C