title: Invoking shell commands using os.system
body: <p>I am trying to use <code>os.system</code> to invoke an external (piped) shell command:</p>
  
  <pre><code>srcFile = os.path.abspath(sys.argv[1])
  
  srcFileIdCmd = "echo -n '%s' | cksum | cut -d' ' -f1" % srcFile
  
  print "ID command: %s" % srcFileIdCmd
  
  srcFileID = os.system(srcFileIdCmd)
  
  print "File ID: %s" % srcFileID
  </code></pre>
  
  <p>outputs</p>
  
  <pre><code>ID command: echo -n '/my/path/filename' | cksum | cut -d' ' -f1
  File ID: 0
  </code></pre>
  
  <p>But when I run </p>
  
  <pre><code>echo -n '/my/path/filename' | cksum | cut -d' ' -f1
  </code></pre>
  
  <p>manually on a command line, I get <code>2379496500</code>, not 0.</p>
  
  <p>What do I need to change to get the correct value out of the shell command?</p>