Hi all,
I need to redirect stdout and stderr to a file in a ksh shell. That's not a problem. But I need also the correct exit code for the executed command. In the example below I redirect correctly the stdout & stderr to a file, but I have the exit code of tee command and not for the mv command.
The script:
#!/bin/ksh
(
mv files.log file.log
EXITSTATUS=$?
if [ ${EXITSTATUS} -ne 0 ]
then
exit ${EXITSTATUS}
fi
) 3>&1 1>&2 2>&3 |tee -a logfile
echo $?
echo "exit code" $EXISTATUS
here is the output:
mv: rename files.log to file.log: No such file or directory
0
exit code
here is the logfile:
mv: rename files.log to file.log: No such file or directory
Please, could anyone help me?
Thanks, bye