Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Error f = open(r'D:\NetAuto\myswitches.txt')
Hi all,
This is my code:
import getpass
import sys
import telnetlib

user = raw_input("Enter your telnet username: ")
password = getpass.getpass()

f = open(r'D:\NetAuto\myswitches.txt')

for line in f:
	print "configuring Switch " + (line)
	HOST = line
	tn = telnetlib.Telnet(HOST)

tn.read_until("Username: ")
tn.write(user + "\n")
if password:
	tn.read_until("Password: ")
	tn.write(password + "\n")

tn.write("conf t\n")
for n in range(40,51):
	tn.write("vlan " + str(n) + "\n")
	tn.write("name Python_VLAN_" + str(n) + "\n")

print tn.read_all()
But there are error for the code:
configuring Switch
Traceback (most recent call last): File "D:\NetAuto\", line 13, in <module> tn = telnetlib.Telnet(HOST) File "C:\Python27\lib\", line 211, in __init__, port, timeout) File "C:\Python27\lib\", line 227, in open self.sock = socket.create_connection((host, port), timeout) File "C:\Python27\lib\", line 557, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno 11001] getaddrinfo failed
Please help me this error
Larz60+ wrote Apr-21-2020, 02:41 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.

Buran gave you a verbal warning about this on your last thread.
Next thread or post without heeding rules may bring hard warning.

Please read the rules bbcode section

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)