Execute a bash command with pipe from python
<p>I wanted to execute a bash command from within python and get the output:</p>

<pre><code>ifconfig | sed '/^$/d' | awk 'NR &gt; 1 { print $2 }'
</code></pre>

<p>I already tried:</p>

<pre><code>p =subprocess.Popen(["ifconfig | sed '/^$/d' | awk 'NR &gt; 1 { print $2 }'"], stdout = PIPE.)
out = p.communicate()
</code></pre>

<p>and dividing the process into smaller ones:</p>

<blockquote>
  <p>p1 and p2 and pass p1 output to p2 but this is not working</p>
</blockquote>

<p>how can I do it?</p>