I assume that you are talking about running commands from IPython using ! escape:
In[1]: !echo hello hello In[2]:
Using Google, I found the documentation, and there is no mention of the exit status of a command that can be written anywhere. Using dir() , I searched for a variable name that might contain this information, and I did not find anything. I tried the syntax x = !ls , and x gets the list of lines of output from the command; there is no exit status.
In short, I don't think IPython even captures this information. At this point, I would like to check the source code in IPython to try to figure out something else.
You can always just run the command with os.system() and get the exit status from it.
In[1]: !launch_eva launch_eva: could not open AT Field In[2]: import os In[3]: exit_status = os.system("launch_eva") launch_eva: could not open AT Field In[4]: exit_status 3 In[5]:
Thus, we see that the launch_eva command returns exit status 3 when it cannot open the AT field.
Seems like this is what IPython should keep. There are many hidden variables. You must submit a request for this feature.
NOTE. This has been tested in IPython 0.10.1 on Ubuntu. Another answer, "piotr", says that the exit code will be fixed in IPython 0.11 due to an exit soon. I cloned the source code from the Git repository to https://github.com/ipython/ipython.git and tested it with python ipython.py ; as piotr said, exit status is stored in a variable called _exit_status .
source share