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
- Qwerty to azerty - Guide
- What is my movie français - Télécharger - Divers TV & Vidéo
- I'm sorry to have to inform you that your message could not be delivered to one or more recipients. it's attached below. ✓ - Forum Mail
- Monitor going to sleep - Forum Windows
- Your browser sent a request that this server could not understand ✓ - Forum Réseaux sociaux
2 réponses
zipe31
Messages postés
36402
Date d'inscription
dimanche 7 novembre 2010
Statut
Contributeur
Dernière intervention
27 janvier 2021
6 407
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
2103
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
21 novembre 2023
259
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 407
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
2103
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
21 novembre 2023
259
4 juil. 2013 à 19:15
4 juil. 2013 à 19:15
Zut grillé... Salut zipe31 !