很难解释我在做什么,但简而言之,pexpect的日志/输出因为我提供的长输入字符串而变得混乱......它类似于Putty会话中发生的事情(物理)窗口大小
例如,
! Using Python
# Python2.6
# Windows 7, Cygwin
# Psuedo-Code - I am giving this
p = pexpect.spawn('ssh Router')
p.sendline('show logging | include MLSCEF-DFC1-2-FIB_TCAM_WRITE_INCONSISTENCY')
i = p.expect('Router#')
print p.before
# Output Seen as
Router# show logging | include MLSCEF-DFC1-2-FIB_TCAM_WRITE$g | include MLSCEF-DFC1-2-FIB_TCAM_WRITE_ INCONSISTe MLSCEF-DFC1-2-FIB_TCAM_WRITE_INCONSISTE NCY
! Using Putty
# This is seen from a tiny putty session for Router
# Really I am just Copy Pasting the line "show logging | include MLSCEF-DFC1-2-FIB_TCAM_WRITE_INCONSISTENCY" into Putty and finally, putty looks like this
ur01.steubenville.oh.pitt#$EF-DFC1-2-FIB_TCAM_WRITE_INCONSISTENCY
# If I increase the windows size of the putty, I see the whole output
ur01.steubenville.oh.pitt#show logging | include MLSCEF-DFC1-2-FIB_TCAM_WRITE_INCONSISTENCY
另一种解释方式,即使是pexpect,这也是正在发生的事情 - http://support.suso.com/supki/File:Nano-pasted-authorizedkeys.png
最终,我希望pexpect增加输入窗口大小,以便我不会看到美元符号($)?