telnetlib error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: telnetlib error (/thread-38883.html) |
telnetlib error - 3lnyn0 - Dec-06-2022 Hi! Please help, what is wrong with my code? I don't know where is the problem. :( import getpass import telnetlib HOST = 'routers' user = input('Enter your username: ') password = getpass.getpass() #f = open('routers') with open('routers') as f: for IP in f: print(IP) IP = IP.strip() print(IP) print('Configuring echipment with IP: ' + (IP)) tn = telnetlib.Telnet(HOST) tn.read_until(b'Username: ') tn.write(user.encode('ascii') + b'\n') if password: tn.read_until(b'Password: ') tn.write(password.encode('ascii') + b'\n') tn.write(b'conf t \n') tn.write(b'int l1 \n') #tn.write(b'ip' + b'add' + b'1.1.1.1' + b'255.255.255.255') #tn.write('int l2\n') #tn.write(b'ip add 2.2.2.2 255.255.255.255\n') print(tn.read_all().decode('ascii'))
RE: telnetlib error - 3lnyn0 - Dec-06-2022 I found the problem! |