[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Exec commande et exit status



Bonjour,

Désolé si cette question est débile mais je deviens fou. Sur ma machine de
test, le retour d'une commande via "exec" est toujours à 0 en script sh.

Exemple :

sleclerc@linux-dev:~$ echo `cp dodo` ; echo $?
cp: missing destination file
Try `cp --help' for more information.

0

La même sans le "exec" :

sleclerc@linux-dev:~$ cp dodo ; echo $?
cp: missing destination file
Try `cp --help' for more information.

1

Même combat si je remplace les `` avec un exec.

A l'origine mon code est le suivant :

------------------------------
#!/bin/sh

DEBUG="N"

Log_err()
{
[ "$DEBUG" = Y ] && set -x
 STATUS=$1 ; ERR_MESS=$2
 if [ $STATUS -gt 0 ] ; then
  echo
  echo "$ERR_MESS" >> $TMP/$TMP.LOG
  [ -n "$LOG" ] && echo "$ERR_MESS" >> $LOG
  if [ "$3" = exit ] ; then
  echo "sortie avec erreur"
  exit 1
  fi
 fi
}

echo `cp toto`
Log_err $? "Manque paramètre pour cp" exit
------------------------------

Je comprend plus rien.

Stef...

..........................................................
.  Linux - Debian - php4 - Apache - MySQL - Infogerance  .
.   email: info@actionweb.fr - http://www.actionweb.fr   .
.     Tel: (0)141 906 100    -    Fax: (0)141 906 101    .
..........................................................



Reply to: