Add Function.sh
This commit is contained in:
1 parent
09e044cb26
commit
462d2699ff
1 file changed
+24
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Recherche sur saisie la présence de $user dans /etc/passwd
|
||||||
|
function exist_user {
|
||||||
|
local VariableLocale="Locale"
|
||||||
|
VariableGlobale="Globale"
|
||||||
|
echo "Saisir le nom d’un utilisateur : \c"
|
||||||
|
read user
|
||||||
|
if grep -q "^$user": /etc/passwd
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if exist_user
|
||||||
|
then
|
||||||
|
echo "L’utilisateur $user existe"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo -e "\033[0;31m L’utilisateur $user n’est pas defini \033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$VariableLocale" # N’est pas récupérée
|
||||||
|
echo "$VariableGlobale" # Disponible
|
||||||
Reference in new issue
Block a user