title: Communicating with smbpasswd with Python subprocesses using stdin/stdout
body: <p>I've been trying to communicate with a program (smbpasswd) using Python's subprocess module without much success. I can communicate with a different program, (e.g. grep) without any trouble, so the problem is specific to smbpasswd. To illustrate the problem, the following code works:</p>
  
  <pre class="lang-python prettyprint-override"><code>&gt;&gt;&gt; p = Popen(["grep", "n"], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
  &gt;&gt;&gt; stdout = p.communicate(input='one\ntwo\n')[0]
  &gt;&gt;&gt; print(stdout)
  one
  </code></pre>
  
  <p>However, the following does not:</p>
  
  <pre><code>&gt;&gt;&gt; p = Popen(["smbpasswd", "-r", server, "-U", user], stdout=PIPE, stdin=PIPE, stderr=PIPE)
  &gt;&gt;&gt; stdout = p.communicate(input='old_password')[0]
  &gt;&gt;&gt; print(stdout)
  </code></pre>
  
  <p>The difference is that grep waits for user input after calling the initial "grep f", while smbpasswd prompts the user to input their old password ("Old SMB password:" is displayed if you run the command in a terminal) before looking for input.</p>
  
  <p>This is, however, where my knowledge ends. Any help is greatly appreciated!</p>