Article 4W3KD How do I get the exit code while directing the command output to a file?

How do I get the exit code while directing the command output to a file?

by
cesarsj
from LinuxQuestions.org on (#4W3KD)
I am canceling the mysql command on purpose to have error exit code. In the command below, the exit code is being 0 successful because of the tee. How can I solve this?

Code:mysql --defaults-extra-file=/etc/my.cnf.d/.mylogin.cnf -e"use radius; call sp_monthly_table_backup(@Msg);" | tee -a $CLEARLOG $ZBXLOG > /dev/null;

EXITCODE=$(echo $?);latest?d=yIl2AUoC8zA latest?i=qoE3wXYii3A:3ux9GvywkB8:F7zBnMy latest?i=qoE3wXYii3A:3ux9GvywkB8:V_sGLiP latest?d=qj6IDK7rITs latest?i=qoE3wXYii3A:3ux9GvywkB8:gIN9vFwqoE3wXYii3A
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments