Python Forum
Issue when running telnet program using python3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue when running telnet program using python3
#11
I think, I'm close finish this up. :))
if password:
        tn.read_until(b"Password:")
        tn.write(password.encode("ascii")+b"\n") 

        tn.read_until(b"#")
        tn.write(b"conf t"+b"\n")
        time.sleep(1)
        tn.write(b"hostname test1"+b"\n")
        tn.write(b"exit"+b"\n")
        tn.write(b"terminal length 0"+b"\n")
        tn.write(b"show run"+b"\n")
##        time.sleep(5)
        
#Save method
        readoutput = tn.read_all()
        tn.write(b"exit"+b"\n")
        saveoutput = open("device" + HOST, "w")
        saveoutput.write(str(readoutput))
        saveoutput.close
        tn.close()
    break
Put a break at the end, and I eliminate the socket error.. But there no data on the file named as device.
Reply
#12
Removed the break for the loop to continue, but Got a new issue... I'm able to finish all task in function like change hostname copy and export the cofig but only for 1 device other device just successfully change the hostname but the writing the configuration into the file that has been created.. :(

https://stackoverflow.com/questions/5389...nto-a-file
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  telnet from ssh tunnel oldfart 3 7,063 Jul-17-2020, 02:28 PM
Last Post: noobami99
  telnet to a device under tacacs management kang18 0 1,540 Jun-05-2020, 06:11 AM
Last Post: kang18
  Selector file descriptor issue in simple multiclient server program dohpam1ne 0 2,887 May-28-2020, 02:39 PM
Last Post: dohpam1ne
  3.6 telnet eyler 3 11,210 Jun-28-2019, 05:22 AM
Last Post: Khanhamid90
  Any suggestion on python library to use for both ssh and telnet? lord_mani 4 3,668 Jun-25-2019, 04:07 PM
Last Post: gb74razor
  telnet question jacklee26 2 2,459 Mar-30-2019, 06:45 AM
Last Post: jacklee26
  Retrieve output from telnet command Networker 1 4,041 Mar-12-2019, 01:36 PM
Last Post: searching1
  Aggregate multiple telnet connections Jibeji 1 4,220 Mar-02-2018, 07:21 PM
Last Post: mpd
  mysql connector/telnet issue (re: text game) rebubula76 1 2,505 Feb-06-2018, 08:00 PM
Last Post: rebubula76
  Multithread telnet not working Parallel anna 7 7,354 Feb-05-2018, 01:17 PM
Last Post: anna

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020