0
>>> ssh_stuff
['yes/no', 'Password:', 'password', 'Are you sure you want to continue connecting']
>>> prompt
['$', '#']
>>> child = pexpect.spawn('ssh [email protected]')
>>> child.expect(ssh_stuff)
1
>>> child.sendline(getpass.getpass())
Password:
11
>>> child.expect(prompt)
0
>>> child.sendline('ls -l')
6
>>> child.expect(prompt)
0
>>> print child.before, child.after
可以告訴我爲什麼我的child.before和之後是空的,它應該返回目錄列表。pexpect child.before和child.after爲空