Hi ,
I have a bash script , which does the network configuration. Messages from this script are dumped on console as well as stored in a log file .
This script is invoked from a C code using system call . The script returns different exit code , to indicate different error cases. The pseudo-code of the script is below
#!/bin/sh
{
.
.
.
# If some error case 1
exit 2
.
.
.
# If some error case 2
exit 4
#script ends here
} 2>&1 |tee -a $LOG_FILENAME
Now the problem is that due to this "pipe tee" to re-direct the messages to log file , the exit status of this script is always 0.
Can some one give some suggestions , so that I can get the correct exit code of this script in my C program , as well as the messages are dumped on console as well as is logged on in a log file .