I am looking to redirect all the output from a python script to output.out
, then upon completion of the python script, write Exited with code: <EXIT CODE HERE>
to the same file where <EXIT CODE HERE>
is the exit code of the python process/script.
I need to do this all in one line which I will be passing to a bash -c
call. I can get the redirection by doing something like this:
bash -c 'python /tmp/test.py > /tmp/all.out 2>&1'
But how do I then take the exit code and write it to /tmp/all.out
?