title: Why does subprocess not return anything when pinging a server on python?
body: <p>I am using subprosess to ping a server, but I want to receive the full response. In the past I have used <code>os</code> to ping but this only returned <code>1</code> or <code>0</code>.</p>
  
  <p>The code that I am using is:</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen(['ping', '8.8.8.8'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, err = p.communicate()
  print out
  </code></pre>
  
  <p>I would like if if the response that I would see if I had ran it from the terminal was visible. Please note that I am using <code>-c</code> and not <code>-n</code> because I am using linux as the OS.</p>
  
  <p>I am confused as to why this does't work because when I ran similar code, it printed out the expected response:</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen(['ls', '-a'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, err = p.communicate()
  print out
  </code></pre>
  
  <p>The code above printed out the list of files and folders in the directory which the python script was saved in, so the code that I am using seems to be correct.</p>
  
  <p>My question is, how can I have the response from pinging a server assigned to a variable that I can then print out like I can when I run <code>ls</code>.</p>