title: Simplest way to run an Expect script from Python
body: <p>I'm trying to instruct my Python installation to execute an <a href="https://en.wikipedia.org/wiki/Expect" rel="nofollow noreferrer">Expect</a> script "myexpect.sh":</p>
  
  <pre><code>#!/usr/bin/expect
  spawn ssh usr@myip
  expect "password:"
  send "mypassword\n";
  send "./mycommand1\r"
  send "./mycommand2\r"
  interact
  </code></pre>
  
  <p>I'm on Windows so re-writing the lines in the Expect script into Python are not an option. Any suggestions? Is there anything that can run it the way "./myexpect.sh" does from a bash shell?</p>
  
  <hr>
  
  <p>I have had some success with the subprocess command:</p>
  
  <pre><code>subprocess.call("myexpect.sh",  shell=True)
  </code></pre>
  
  <p>I receive the error:</p>
  
  <blockquote>
    <p>myexpect.sh is not a valid Win32 application.</p>
  </blockquote>
  
  <p>How do I get around this?</p>