포항돼지 2021. 5. 14. 23:18

import telnetlib

host = '192.168.122.106'
user = 'stz'
password = 'cisco'

mytelnet = telnetlib.Telnet(host = host)

mytelnet.read_until(b'Username: '')
mytelnet.write(user.encode() + b'\n')

mytelnet.read_until(b'Password: '')
mytelnet.write(password.encode() + b'\n')

mytelnet.write(b'show ip int br\n')
mytelnet.write(b'exit\n')

output = mytelnet.read_all()
output = output.decode()
print(output)