[Précédent (date)] [Suivant (date)] [Précédent (sujet)] [Suivant (sujet)] [Index par date] [Index par sujet]
Re: shell script
- To:
- Subject: Re: shell script
- From: "Gilles J. Seguin" <>
- Date: Thu Jun 27 15:22:00 2002
- Newsgroups: qc.comp.os.linux.aide
Nicolas Couture wrote:
>
> On Wednesday 26 June 2002 12:11 pm Fabien Ninoles <[email protected]> wrote
> in <[email protected]>:
>
> Le seul probleme c'est que je n'veux pas savoir s'il y a eu des fichiers
> effaces. Dans ce cas, je n'ai seulement trouve ce que je cherchais avec
> diff. Ce que je veux vraiment faire c'est de ne voir que la difference avec
> le nouveau fichier cree et pas le .old.
>
> <snip>
> #! /bin/sh
[...]
> #
> # vrfy if user is root before executing this script.
> if [ ! "$UID" = "0" ]; then
> echo "You need to be root to run this script."
> exit 1
> fi
>
> # vrfy and create needed files and directories.
> if [ -r ./md5sum ]; then
> mv ./md5sum ./md5sum.old
root par defaut ne permettra pas de copier si
../md5sum.old existe deja
mv -f ./md5sum ./md5sum.old
> for path in `echo $PATH | tr : '\n'`; do
> for file in $path/*; do
L'utilisation d'un patron glob de recherche
va retourner aussi des fichiers repertoire.
Cette commande va aussi surement exceder le tampon
permit, soit 4KByte
if [ -f file ]
then
# ajouter 3> /dev/null pour eliminer les messages d'erreur
> md5sum $file > ./md5sum; done;
#elif traitement des link qui peuvent etre recursif
fi
> done;
> else if [ ! -r ./md5sum ]; then
> for path in `echo $PATH | tr : '\n'`; do
> for file in $path/*; do
utiliser un fichier tampon temporaire et l'utilitaire find
> md5sum $file > ./md5sum; done;
> done; fi;
> fi;
>
> if [ -r ./suid ]; then
> mv ./suid ./suid.old
> find / \( -perm -004000 -o -perm -002000 \) -type f -print >
> ../suid; else
> find / \( -perm -004000 -o -perm -002000 \) -type f
> -print > ./suid ; fi
>
> if [ -r ./guid ]; then
> mv guid ./guid.old
> find / -group kmem -perm -2000 -print > ./guid; else
> find / -group kmem -perm -2000 -print > ./guid; fi
>
> # vrfy if any new suid file(s) have being created.
> echo
> if [ "$(diff suid suid.old | grep "<" | cut -d " " -f2)" = "" ];
l'option -q permet d'oter les messages d'erreur
> then
> echo "No new suid file found."; fi
>
> if [ "$(diff suid suid.old | grep "<" | cut -d " " -f1)" = "<" ];
> then
> echo "The fallowing suid file(s) has being added: "
> diff suid suid.old | grep "<" | cut -d " " -f2; fi
>
> # vrfy if any new suid file(s) have being created.
> echo
>
> if [ "$(diff guid guid.old | grep "<" | cut -d " " -f2)" = "" ];
> then
> echo "No new guid file found."; fi
>
> if [ "$(diff guid guid.old | grep "<" | cut -d " " -f1)" = "<" ];
> then
> echo "The fallowing guid file(s) has being added: "
> diff guid guid.old | grep "<" | cut -d " " -f2; fi
>
> # vrfy if any executable didnt respond correctly to their md5sum.
> echo
> if [ "$(diff md5sum md5sum.old | grep "<" | cut -d " " -f4)" = ""
> ]; then
> echo "All executables responded correctly to their md5sum.";
> echo
> exit 1; fi
>
> echo "The Fallowing file(s) didnt answer correctly to their
> md5sum or have being added:"
> diff md5sum md5sum.old | grep "<" | cut -d " " -f4
>
> # Output the bad md5sums.
> echo "With the md5sum(s): "
> diff md5sum md5sum.old | grep "<" | cut -d " " -f2