Is it possible to run a command to redirect output and standard error in a file and know the return code of the command ?
./COMMANDE.sh 2>&1 | tee -a $LOG_DIRECTORY/$LOG_FILE
if [ $? = 0 ]; then
echo "OK"
else
echo "KO"
exit 1
fi
Currently, I get the return code of the tee command, I want to recover that of COMMANDE.sh.