我用pexpect出错,这是为什么呢?

#!/usr/bin/python
import pexpect
child = pexpect.spawn ('ftp hostname')
child.expect ('Name .*: ')
child.sendline ('name')
child.expect ('Password:')
child.sendline ('123456')
child.expect ('ftp> ')
print child.before
child.interact()
首先是启动后,每次我必须按一下enter后才显示子进程的ftp>
其次是我按by后,
ftp> by
221 Goodbye.
Traceback (most recent call last):
  File "./bb.py", line 10, in ?
    child.interact()
  File "/usr/lib/python2.3/site-packages/pexpect.py", line 1229, in interact
    self.__interact_copy(escape_character, input_filter, output_filter)
  File "/usr/lib/python2.3/site-packages/pexpect.py", line 1249, in __interact_copy
    data = self.__interact_read(self.child_fd)
  File "/usr/lib/python2.3/site-packages/pexpect.py", line 1242, in __interact_read
    return os.read(fd, 1000)
OSError: [Errno 5] Input/output error

有人知道这是为什么吗?