Skip to content
Snippets Groups Projects
lookingGlass.py 774 B
Newer Older
import getpass
import sys
import telnetlib
import time

HOST = "localhost"
tn = []

def empty_test(output, i):
    if(len(output)>0):
        print("Info R",i+1)
        print(output)

def telnetCommunication():
    for i in range(0,2):
        print(i)
        tn.append(telnetlib.Telnet(HOST,5000+(i)))
        (tn[i]).read_until(b'show')
        (tn[i]).write(b'show ip int br\n')
        (tn[i]).write(b"\x0D")
        output = ((tn[i]).read_very_eager().decode('ascii'))
        time.sleep(2)

def telnetUpdates():
    while True:
        for i in range(0,2):
            (tn[i]).read_until(b'')
            output = ((tn[i]).read_very_eager().decode('ascii'))
            time.sleep(5)
            empty_test(output, i)
      
telnetCommunication()
telnetUpdates()