title: How do I enter a password after subprocess.call()
body: <p>I am trying to build a python script that I have run every day to fetch that days DNS requests from OpenDNS from the previous 2 days. This is what I have so far. </p>
  
  <pre><code>import subprocess
  import datetime
  two = datetime.date.today() - datetime.timedelta(2)
  one = datetime.date.today() - datetime.timedelta(1)
  path = '~/Downloads/opendns-fetchstats-master'
  dateRange = str(two) + ' ' + str(one)
  dateRange2 = str(two) + 'to' +str(one)
  username = 'email@email.com'
  password = 'password'
  outputFile = dateRange2 + '.csv'
  print dateRange2
  subprocess.call(
      ['cd ' + str(path) + ' &amp;&amp; echo '+ str(password) + ' | bash fetchstats ' +
      str(username) + ' home ' + str(dateRange) + ' &gt; ' + str(outputFile)],
      shell=True
      )
  </code></pre>
  
  <p>The problem is that after it runs:</p>
  
  <pre><code>bash fetchstats ' + str(username) + ' &lt;network_id&gt; ' + str(dateRange) + ' &gt; ' + str(outputFile)
  </code></pre>
  
  <p>it then asks for the password to the account. I can not figure out how to input the password. My attempt at using </p>
  
  <pre><code>echo password |
  </code></pre>
  
  <p>works partially but the process returns the error below and the process ends before all the data can be downloaded</p>
  
  <blockquote>
    <p>stty: 
    standard input: Inappropriate ioctl for device
    stty: standard input: Inappropriate ioctl for device</p>
  </blockquote>
  
  <p>Is there a way I can write this so the process enters the password when prompted and then waits until the download is complete before ending the process?</p>