telnetlib. configure hostnames - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: telnetlib. configure hostnames (/thread-21165.html) |
telnetlib. configure hostnames - lado - Sep-17-2019 Hello everyone I'm new in Python networking world. So I need you help. My goal is to configure different Hostnames for devices. for example Device_IP Hostname 192.168.1.1 TEST1 192.168.1.2 TEST2 I made excel document with IP address and Hostnames and wrote some script, but something is not work(( import telnetlib import pandas as pd df1 = pd.read_excel("nodes.xlsx",sheet_name='Sheet1') df1list=df1.values.tolist() for a in df1list: HOSTNAME=a[0] DEVICE_IP=a[1] try: HOST = DEVICE_IP user = "root" password = "" tn = telnetlib.Telnet(HOST,timeout=3) tn.read_until(b"Login: ") tn.write(user.encode('ascii') + b"\n") tn.read_until(b"Password: ") tn.write(password.encode('ascii') + b"\n") tn.write(b"/system identity user= + HOSTNAME \n") tn.write(b"exit \n") router_output = tn.read_all().decode('ascii') print(HOSTNAME+' '+DEVICE_IP,"Success") print(router_output) tn.close() except Exception as e: print(DEVICE_IP,"FAILED")Can you help me to understand what is wrong? Thank you .. RE: telnetlib. configure hostnames - matya0403 - May-30-2020 tn.read_until(b"Login: ") - check this (b"username") , may this is username |