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
Post a Comment