shell bash - return code -


is possible run command redirect output , standard error in file , know return code of command ?

./commande.sh 2>&1 | tee -a $log_directory/$log_file if [ $? = 0 ];     echo "ok" else     echo "ko"     exit 1 fi 

currently, return code of tee command, want recover of commande.sh.

you want pipestatus.

./commande.sh 2>&1 | tee -a $log_directory/$log_file if [ ${pipestatus[0]} = 0 ];     echo "ok" else     echo "ko"     exit 1 fi 

the index array ([0]) index of command in pipe chain executed (./commande.sh). ${pipestatus[1]} tee.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -