Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Demande de confirmation en shell

5 réponses
Avatar
Lucas Levrel
Bonjour,

C'est sûrement assez simple, mais je ne sais pas faire : comment, dans un
script shell (bash), demander confirmation à l'utilisateur avant la
poursuite du script ?

echo "Poursuivre (o/n) ?"
if ???
then exit 1
fi
...

Merci.

--
LL

5 réponses

Avatar
Sergio
Le Tue, 16 Apr 2013 16:11:51 +0200, Lucas Levrel a écrit :

Bonjour,

C'est sûrement assez simple, mais je ne sais pas faire : comment, dans
un script shell (bash), demander confirmation à l'utilisateur avant la
poursuite du script ?

echo "Poursuivre (o/n) ?"
if ???
then exit 1 fi ...



echo -n "Poursuivre (o/n) ?"
# Le -n pour éviter un retour à la ligne
read rep
case $rep in
o|O|y|Y) echo "On continue"
n|N) echo "Non, c'est non"
*) echo "Vous avez dit ?"
esac
Avatar
admint
Le 16/04/2013 16:11, Lucas Levrel a écrit :
Bonjour,

C'est sûrement assez simple, mais je ne sais pas faire : comment, dans
un script shell (bash), demander confirmation à l'utilisateur avant la
poursuite du script ?

echo "Poursuivre (o/n) ?"
if ???
then exit 1
fi
...

Merci.




Salut
Plutôt qq chose comme ça :)

echo -n "On continue (o/n)? "
read rep1

case "$rep1" in
o|O)
echo "OK : reponse oui"
;;

n|N)
echo "Abandon..."
exit 1
;;
esac


Patrick
Avatar
william
On 2013-04-16, Lucas Levrel wrote:
Bonjour,

C'est sûrement assez simple, mais je ne sais pas faire : comment, dans un
script shell (bash), demander confirmation à l'utilisateur avant la
poursuite du script ?

echo "Poursuivre (o/n) ?"
if ???
then exit 1
fi



bon allez pour le fun

dialog --yesno "ben tu veux ou pas ?" "5" "30

if [ $? -eq 0 ] ; then
// cool
elif [ $? -eq 1 ] ;
// pas cool
fi
Avatar
Lucas Levrel
Le 18 avril 2013, william a écrit :

bon allez pour le fun

dialog --yesno "ben tu veux ou pas ?" "5" "30



Pas bon, parce que ça efface le contenu du terminal.
;-)

--
LL
Avatar
Lucas Levrel
Merci pour toutes les réponses.

--
LL