很难解释我在做什么,但简而言之,由于我提供的输入字符串很长,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
最终,我希望增加输入窗口的大小,这样我就看不到美元符号 ($)?