Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python PitfallsRead Python Pitfalls

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python Pitfalls

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python Pitfalls

deleted 307 characters in body
Source Link
Rahul Patil
  • 25.6k
  • 26
  • 85
  • 96

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python Pitfalls

Update 1#

I also want to see whether my shell script has any problem while executing from Python. If yes, then I don't want to print end statement.

So you need to define set -e in your shell script at top off, then script will exit with non zero status, then you can evaluate in Python.

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python Pitfalls

Update 1#

I also want to see whether my shell script has any problem while executing from Python. If yes, then I don't want to print end statement.

So you need to define set -e in your shell script at top off, then script will exit with non zero status, then you can evaluate in Python.

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python Pitfalls

Source Link
Rahul Patil
  • 25.6k
  • 26
  • 85
  • 96

From Python Subprocess Doc :

Popen.returncode

The child return code, set by poll() and wait() (and indirectly by communicate()). A None value indicates that the process hasn’t terminated yet.
A negative value -N indicates that the child was terminated by signal N (Unix only).

So you can check exit status using :

proc.returncode

but it's bit ironic thing is zero 0 means False in Python.

Example :

if (var == False) :
    # this will execute if var is False or 0 (or 0.0, 0L, 0j)

Read Python Pitfalls

Update 1#

I also want to see whether my shell script has any problem while executing from Python. If yes, then I don't want to print end statement.

So you need to define set -e in your shell script at top off, then script will exit with non zero status, then you can evaluate in Python.