exit status
I have a C application that returns a value to the shell.
Code:
exit(status); echo $? but, when I use it in the following way, I always get 0 even when status is not 0: c_app | mutt -s "$?" email.address mutt is a mail program, -s "subject line" What is overwriting $? ? |
Hi Naflan,
You actually have two problems here. The first is that $? is evaluated by the shell before it even thinks about running your program. The second is that mutt is actually started before c_app finishes, such is the nature of piped execution, so mutt could never get the return value of c_app anyway. As far as I can tell the only simple way to do what you want is to use an intermediate file for the output, then invoke mutt on the next line to read the file back, but maybe there is a more cunning solution. TIM |
Thanks Avarus,
I thought that I would have to do this with a script. 1. c_app > temp.txt 2. capture $? in a variable. 3. Run mutt using the variable in my subject line. mutt -s "$variable" email@address.com < temp.txt Quote:
naflan |
All times are GMT -5. The time now is 08:12 PM. |