How to get the exit status set in a shell script in python
Question: i want to get the exit status set in a shell script which has been called from
python. the code is as below

python script.

    
    
    result = os.system("/compile_cmd.sh")
    print result
    

(compile_cmd.sh)

    
    
    javac @source.txt
    #i do some code here to get the no of compilation errors
    if [$error1 -e 0 ]
    then
    echo "\n********** JAVA compilation sucessfull **********"
    exit 0
    else
    echo "\n** JAVA Compilation Error in file ** File not checked in to CVS **"
    exit 1
    fi
    

i am running this code. but no matter the what exit status i am returning, i
am getting result var as 0 (i think its returning whether shell script was run
successfully or not) Any idea how i can fetch the exit status that i am
setting in the shell script in the python script??


Answer: 
    import subprocess
    result = subprocess.Popen("./compile_cmd.sh")
    text = result.communicate()[0]
    returncode = result.returncode
    

Taken from here: [How to get exit code when using Python subprocess
communicate method?](http://stackoverflow.com/questions/5631624/how-to-get-
exit-code-when-using-python-subprocess-communicate-method)

