pexpect python throw error
<p>Although this is my first attempt at using pexpect, the python3 script using pexpect is pretty simple; yet it fails. </p>

<pre><code>#!/usr/bin/env python3
import sys
import pexpect

SSH_NEWKEY = r'Are you sure you want to continue connecting \(yes/no\)\?'

child = pexpect.spawn("ssh -i /user/aws/key.pem ec2-user@xxx.xxx.xxx.xxx date")
i = child.expect( [ pexpect.TIMEOUT, SSH_NEWKEY )
if i == 1:
   child.sendline('yes')
print(child.before)
</code></pre>

<p>The SSH_NEWKEY is the only response I'm expecting, but the example showed a list containing pexpect.TIMEOUT in it so I used it.  </p>

<pre><code>$ ./test.py 
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pexpect/spawnbase.py", line 144, in read_nonblocking
    s = os.read(self.child_fd, size)
OSError: [Errno 5] Input/output error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/pexpect/expect.py", line 97, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/usr/local/lib/python3.4/site-packages/pexpect/pty_spawn.py", line 455, in read_nonblocking
    return super(spawn, self).read_nonblocking(size)
  File "/usr/local/lib/python3.4/site-packages/pexpect/spawnbase.py", line 149, in read_nonblocking
    raise EOF('End Of File (EOF). Exception style platform.')
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./min.py", line 15, in &lt;module&gt;
    i = child.expect( [ pexpect.TIMEOUT, SSH_NEWKEY  ] )
  File "/usr/local/lib/python3.4/site-packages/pexpect/spawnbase.py", line 315, in expect
    timeout, searchwindowsize, async)
  File "/usr/local/lib/python3.4/site-packages/pexpect/spawnbase.py", line 339, in expect_list
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.4/site-packages/pexpect/expect.py", line 102, in expect_loop
    return self.eof(e)
  File "/usr/local/lib/python3.4/site-packages/pexpect/expect.py", line 49, in eof
    raise EOF(msg)
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
&lt;pexpect.pty_spawn.spawn object at 0x7f70ea4fbcf8&gt;
command: /usr/bin/ssh
args: ['/usr/bin/ssh', '-i', '/user/aws/key.pem', 'ec2-user@xxx.xxx.xxx.xxx', 'date']
searcher: None
buffer (last 100 chars): b''
before (last 100 chars): b'Fri May  6 13:50:18 EDT 2016\r\n'
after: &lt;class 'pexpect.exceptions.EOF'&gt;
match: None
match_index: None
exitstatus: 0
flag_eof: True
pid: 31293
child_fd: 5
closed: False
timeout: 30
delimiter: &lt;class 'pexpect.exceptions.EOF'&gt;
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
</code></pre>

<p>What am I missing?</p>

<p>CentOS 6.4
python 3.4.3</p>