Tester STDIN en KSH

Résolu/Fermé
gunbol Messages postés 47 Date d'inscription mercredi 19 septembre 2007 Statut Membre Dernière intervention 18 mars 2016 - 23 janv. 2009 à 11:55
gunbol Messages postés 47 Date d'inscription mercredi 19 septembre 2007 Statut Membre Dernière intervention 18 mars 2016 - 30 janv. 2009 à 17:08
Bonjour,

Existe-t-il un moyen en KSH de tester stdin.

Je souhaiterais tester si un stdin existe quand un script est appelé.

example:
./monscript.ksh < fichier_input.txt
===> OK

./monscript.ksh
===> KO

Merci d'avance.

Gunther
A voir également:

3 réponses

dubcek Messages postés 18718 Date d'inscription lundi 15 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 5 615
23 janv. 2009 à 13:14
hello
essayer
if [ -t 0 ] ; then
   echo KO
else
  echo OK
fi
3
Le Korn-sheller fou
30 janv. 2009 à 16:03
Ceci marche (je l'utilise très régulièrement dans mes scripts):

/bin/stty > /dev/null 2>&1
if [ $? -ne 0 ]
then
# Stdin provided
echo "===> OK"
else
# No input
echo "===> KO"
fi

Bonne adaptation
0
gunbol Messages postés 47 Date d'inscription mercredi 19 septembre 2007 Statut Membre Dernière intervention 18 mars 2016 4
30 janv. 2009 à 17:08
Hello,

Merci pour vos réponses. Je l'ai utilisé dans mon script, ca marche nickel ;o)
0