title: pexpect: expect various lines
body: <p>I am trying to use pexpect to scp files from a server, but it seems to do nothing (not even an error message). Here is my code:</p>
  
  <pre><code>import pexpect
  child=pexpect.spawn('scp -r user@host:route/file .')
  child.expect("user@host's password:")
  child.sendline('password')
  </code></pre>
  
  <p>I think that problem is in the child.expect command, because  "user@host's password:" is the last line of a some 30 lines welcome message which include special caracters. Is there any way to tell pexpect to expect more than one line or simply anything? Or just to wait X secs and then input the password?</p>
  
  <p>EDIT: It works with the child.wait() command, but it stops at the 9th file. It happens that the 10th is very big (about 250Mb), I don't know if it has something to do with it... Thank you!!</p>
  
  <p>EDIT: I put the line</p>
  
  <pre><code>child.logfile=sys.stdout
  </code></pre>
  
  <p>after</p>
  
  <pre><code>child=pexpect.spawn('scp -r user@host:route/file .')
  </code></pre>
  
  <p>and what I get in the screen, NOT in a file, is the welcome message which finishes by "user@host's password:", then I saw the password in the same line, but I still don't get the files.</p>
  
  <p>Anyone knows how to fix it?</p>
  
  <p>Thank you everyone!</p>