title: Get return value from shell command in python
body: <p>I'm doing <code>os.system</code> to tail for a live file and <code>grep</code> for a string 
  How can I execute something when the grep succeeds? 
  For example</p>
  
  <pre><code>cmd=  os.system(tail -f file.log | grep -i abc)
  if (cmd):     
           #Do something and continue tail
  </code></pre>
  
  <p>Is there any way I can do this? It will only come to the <code>if</code> block when the os.system statement is completed.</p>