Hi i am still facing the same kind of issue.
Below is my code
Below is my code
import telnetlib import getpass p=open("ipadd.txt") user=input("Please Enter the Username: ") password=getpass.getpass() for line in p: print("Configuring Switch with IP : "+line) HOST=str(line.split()) tel=telnetlib.Telnet(HOST) tel.read_until(b"Username:") tel.write(user.encode("ascii")+b"\n") if password: tel.read_until(b"Password:") tel.write(password.encode("ascii")+b"\n") tel.write(b"conf t \n") for x in range(10,20): tel.write(b"vlan "+str(x).encode("ascii")+b"\n") tel.write(b"exit \n") tel.write(b"end \n") tel.write(b"wr \n") tel.write(b"exit \n") print(tel.read_all().decode("ascii")) p.close()Here is the output, with error
Error:Please Enter the Username: cisco
Password:
Configuring Switch with IP : 10.10.10.50
[error]Traceback (most recent call last):
File "c:/Users/Nemat/Python/openswitches.py", line 13, in <module>
tel=telnetlib.Telnet(HOST)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\telnetlib.py", line 218, in __init__
self.open(host, port, timeout)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\telnetlib.py", line 234, in open
self.sock = socket.create_connection((host, port), timeout)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\socket.py", line 707, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1520.0_x64__qbz5n2kfra8p0\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
can some one help in this matter