How to capture the standard output of command in python script
for example , I want to check if tar command success or not and results will be return in stndStatus value
import commands
def runCommandAndReturnValue():
status,output = commands.getstatusoutput(" tar xvf Test.tar ")
return stndStatus
other example - its like $? in shell scripts so stndStatus will be the value of $?
stndStatusis not defined anywhere. Linux commands typically return 0 if successful and an 8-bit signed integer corresponding to an error code otherwise. There is no standard definition of the other error codes, really. Only that zero indicates success.