(/bin/foo ; echo $? >RES)| tee -a $LOGFILE export ERR=$(cat RES)