Prompt avec reponse par defaut dans les 5 secondes
Résolu/Fermé
A voir également:
- This process is automatic. your browser will redirect to your requested content shortly. please allow up to 5 seconds
- What is my movie français - Télécharger - Divers TV & Vidéo
- Qwerty to azerty - Guide
- Press esc in 1 seconds to skip startup.nsh any other key to continue - Forum Windows 10
- Video to video - Télécharger - Conversion & Codecs
- Majuscule to minuscule - Guide
2 réponses
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 422
4 juil. 2013 à 19:11
4 juil. 2013 à 19:11
Salut,
man read
man read
$ cat foo.sh #! /bin/bash read -t 5 -p " Voulez-vous continuez (O/N) ? " if [ "$?" -eq 142 ] then REPLY=N fi case ${REPLY} in O) echo -e "\nChoix = Oui";; N) echo -e "\nChoix = Non";; esac $ ./foo.sh Voulez-vous continuez (O/N) ? O Choix = Oui $ ./foo.sh Voulez-vous continuez (O/N) ? N Choix = Non $ ./foo.sh Voulez-vous continuez (O/N) ? Choix = No
Flachy Joe
Messages postés
2102
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
21 novembre 2023
260
4 juil. 2013 à 19:13
4 juil. 2013 à 19:13
Salut,
D'après la doc ( https://ss64.com/bash/read.html ) l'option -t permet de définir un timeout après lequel la commande renvoi faux, exemple :
D'après la doc ( https://ss64.com/bash/read.html ) l'option -t permet de définir un timeout après lequel la commande renvoi faux, exemple :
#!/bin/bash echo "Entre du texte..." read -t 5 answer if [ $answer ] then echo "reponse : $answer" else echo "trop tard" fi;
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 422
4 juil. 2013 à 19:14
4 juil. 2013 à 19:14
Salut,
else
echo "trop tard"
;-DD
else
echo "trop tard"
;-DD
Flachy Joe
Messages postés
2102
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
21 novembre 2023
260
4 juil. 2013 à 19:15
4 juil. 2013 à 19:15
Zut grillé... Salut zipe31 !