I'm trying to figure out how to capture a return value from a python script in a *nix terminal. I'm using Linux.
So, for clarity, I have a converter script where you pass the Python script a number (as a string), it typecasts it, converts it and returns a number using sys.exit(status_number). I understand that I am taking advantage of the return status, but it something that I would like to be able to do.
The only thing I cannot figure out is how to capture that return status in a variable. I know one can do retVal=4, but one cannot, however, expect something like retVal=python foo.py 111 to work.
How can I do this?
retVal=python foo.py 111sets the environmentretValto the valuepythonwhile executingfoo.pywith the argument111... so it is in fact valid shell syntax, even though it isn't what you actually want. :)