title: Calling nbtstat command using subprocess
body: <p>I have a python script which calls the Window's nbtstat command, using subprocess, in order to get the hostname of a computer from its IP address. This is done in cmd using:</p>
  
  <p><code>nbtstat -A 172.16.137.2</code></p>
  
  <p>Running the below script results in a <strong>WindowsError: [Error 2] The system cannot find the file specified</strong>:</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen(['nbtstat', '-A', '172.16.137.2'], std=subprocess.PIPE)
  </code></pre>
  
  <p>I also tried running nbtstat using cmd but got the error message: <strong>'nbtstat' is not recognized as an internal or external command, operable program or batch file.</strong>:</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen(['cmd', '/c', 'nbtstat', '-A', '172.16.137.2'], stdout=subprocess.PIPE)
  </code></pre>
  
  <p>I don't understand why the nbtstat command works in the command prompt, but not within the script.</p>