Hello I'm running into a problem while trying to collect the exit status of a command which is executed in background and which also is part of a piped set of commands..
For examples if 'a' and 'b' are commands, I'm running a | b &
And i need to get exit status of 'a'
My code snippet is shown below:
Code:
a.sh | tee -a $logfile &
wait $!
<now how do i get return status of a.sh>
PIPESTATUS[] didnt work and I also read in bash ref manual that it works only on foreground pipes... And doing $? after wait command is not returning me the status of a.sh.. I guess it would return exit-status of last command in pipe...
Any help is appreciated
Thanks for your time!!!