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와 after가 비어 있기 때문에 디렉토리 목록을 반환해야합니다.pexpect child.before 및 child.after가 비어 있습니다.