0

I am executing a bash script using subprocess module.

subprocess.call(['temp.sh'])

As per python if the temp.sh file is present it calls the script and it doesn't worry about the success or failure of temp.sh. I want to capture the exit code of temp.sh in order to proceed further with rest of my python script.

AdminBee
  • 22,803

1 Answers1

2

The subprocess.call function returns a returncode object, which is an int. It will be the value of the exit code of the subprocess process.

>>> foo = subprocess.call(['/usr/bin/true'])
>>> foo
0
>>> foo = subprocess.call(['/usr/bin/false'])
>>> foo
1
jsbillings
  • 24,406