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

javascript - Trigger mouseenter when an animated element touches mouse -

json - Zend error Connection -

java - Using Spring @Transactional with a combination of readOnly and write, when does this entity get committed? -