(Sep-24-2017, 07:13 PM)buran Wrote: Don't know about your problem, but have an advise to proper handle the file
with open('ips.txt') as f: for line in f: HOST = line.strip() tn = telnetlib.Telnet(HOST) tn.read_until("Username: ") tn.write(user + "\n") tn.read_until("Password: ") tn.write(password + "\n") tn.write("enable\n") tn.write("cisco\n") tn.write(" conf t \n") tn.write("int loop 0 \n") tn.write("int ip add 1.1.1.1 255.255.255.255 \n") tn.write("exit \n")
I did the change but now it is just getting the last ip address, but I did a counter and printed out the
"HOST" and is showing the 3 ip address, and the counter is starting from 1 until 3...
so the reading is correct.
But Why is just creating one telnet connection ? the last one
I did a debung on two devices, one that is working and other that it is not.
How you can see, both devices show and create a telnet session, but just one is changing the hostname
to "foda".