title: Python Subprocess returncode - different results
body: <p>I came to run a script on a production box, and it failed in one of it's first checks. I've narrowed it down to the fact my "ping" check (invoked by subprocess) is returning a non-zero result.</p>
  
  <p>Here's the code in it's simplest form:</p>
  
  <pre><code>import subprocess
  import sys
  ip="127.0.0.1"
  ping = subprocess.Popen(["ping", "-c", "2", "-w", "1", ip], shell=False)
  ping.wait()
  if ping.returncode != 0:
      print ping.returncode, "ERROR: failed to ping host. Please check."
      sys.exit(1)
  else:
      print "OK"
  </code></pre>
  
  <p>Both servers are CentOS 5.5 &amp; Python 2.4.3, but one works and one doesn't!</p>
  
  <p>From the command line a manual ping (of 127.0.0.1) returns 0 in both cases. Why is their a difference when using the subprocess module in python?</p>
  
  <p>Cheers.</p>