Bash Shell - PIPESTATUS
Hey all,
I have a bash script that runs this command: Code:
./myExpTest.exp $1 $2 | tee ~/Documents/Expect_script/new/myTestTee.txt Anyone know why it isn't returning the 2nd exit status to me? I also tried this: (instead of the above example) Code:
./myExpTest.txt $1 $2 | tee ~/Documents/Expect_script/new/myTestTee.txt the first echo with '*' gives me: "0 0" --> which is correct the second echo with '0' gives me: "0" --> also correct the third echo with '1' gives me: " " --> echos nothing Anyone know why this is happening? Am I using it correctly? Thanks in advance, Matt |
*
On further testing I found that the command below will echo both of the exit status' correctly if their on the same line. Code:
$> echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} |
I suspect it's analogous to $?.
There's one and only one copy of this generic cmd completion status var and every cmd issued updates it, so you have to test it immediately after running the cmd you want to check. The act of testing it is another cmd, so the status changes again. |
Hey Chris,
Thanks for the response. I get that $? changes/overwritten on any cmd given, that's what led me to find the PIPESTATUS array variable in the bash shell. Is the $? var related to the PIPESTATUS var? Basically I just want to get the exit status of the 2 given commands using the PIPESTATUS variable and store it in my own variable to do some conditional statements on it. What would be the best way to do that? |
All times are GMT -5. The time now is 04:50 AM. |