title: How to pipe the output of a command to `/dev/null` in python
body: <p>I am trying to pipe the output of the following command to <code>/dev/null</code> so that it doesn't get printed for the user that is running the program.</p>
  
  <pre><code>import os
  os.system("ping -c 1 192.168.unknown.host &gt; /dev/null")
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>ping: unknown host  192.168.unknown.host
  </code></pre>
  
  <p>The problem is that this message is produced by something other than <code>stdout</code>, probably <code>stderr</code> and I can easily redirect it to <code>/dev/null</code> using</p>
  
  <pre><code>ping -c 1 192.168.unknown.host &gt;&amp; /dev/null
  </code></pre>
  
  <p>However, when I use that in python, I get the following error:</p>
  
  <pre><code>sh: 1: Syntax error: Bad fd number
  </code></pre>
  
  <p>Is it possible to solve this? (I just don't want that message to be printed).</p>