title: Hadoop commands from python
body: <p>I am trying to get some stats for a directory in hdfs. I am trying to get the no of files/subdirs and the size for each. I started out thinking that I can do this in bash.</p>
  
  <pre><code>#!/bin/bash
  OP=$(hadoop fs -ls hdfs://mydirectory)
  echo $(wc -l &lt; "$OP")
  </code></pre>
  
  <p>I only have this much so far and I quickly realised that python might be a better option for this. However I am not able to figure out how to execute hadoop commands like <code>hadoop fs -ls from python</code> </p>