Uzak sunucuya bağlanmak için Pexpect modülünü kullanıyorum. Başarıyla yanıt gönderip alabilirim. Önemsiz bir şey bekliyor ve tampon temizleyeceğini varsayarak bir tampon temizlemeye çalışıyorum ama aslında tampon temizlemiyor.
Aşağıda örnek kodum
import pexpect
obj = pexpect.spawn("telnet 172.16.250.250", maxread=8192)
obj.sendline("")
result = obj.expect(expected, timeout=3) --> getting output here `OUTPUT 1`
obj.sendline("1")
time.sleep(3)
try:
obj.expect("Asdfgdsad", timeout=2) --> I am expecting to clear buffer here but it did not
except pexpect.TIMEOUT:
pass
print("buffer is", obj.buffer) . --> This is printing output `OUTPUT 1` as I have meniotned
Burada yanlış bir şey yapıyorum ?? Python3.7 kullanıyorum. Doğru hatırlıyorsam python2.X içinde düzgün çalışıyordu