Extending the question as suggested by Cyrus, I wanted to know if I could track the same script with PIPESTATUS
or something similar if I sent it to run in background?
bash script is as follows:
#! /bin/bash
{ python script.py 2>&1 | tee logfile.log; } &
ret="${PIPESTATUS[0]}"
if [[ "$ret" -ne "0" ]]; then
echo "$ret"
fi
and script.py
is:
print("hello")
exit(1);
print("world")
When I run the bash
script without &
it prints the PIPESTATUS
correctly but in case when I run it in background, no output is returned.