Developer

last person joined: 3 days ago 

Expand all | Collapse all

Can't connect to switch via telnet script(Python3)

Jump to Best Answer
  • 1.  Can't connect to switch via telnet script(Python3)

    Posted May 14, 2020 10:59 AM

    Hello everyone,i have a problem:I can't connect via python script to switch,using telnetlib module:

    Script:

     

     

     

    import getpass
    import telnetlib
    
    HOST = "10.255.23.10"
    user = input("Enter your account: ")
    password = getpass.getpass()
    
    tn = telnetlib.Telnet(HOST)
    
    tn.read_until(b"Username: ")
    tn.write(user.encode('ascii') + b"
    ") if password: tn.read_until(b"Password: ") tn.write(password.encode('ascii') + b"
    ") tn.write(b"show version
    ") print(tn.read_all().decode('ascii'))

     

     

     

     

    And what's happening:
    python.JPG
    After input password nothing happened.
    I don't know why.

    HP J9774A 2530-8G-PoEP Switch

    What's wrong???




  • 2.  RE: Can't connect to switch via telnet script(Python3)

    Posted May 15, 2020 02:59 AM

    Hi,

     

    What firmware version ?

     

    Why don't use API ? it is will be more easy...



  • 3.  RE: Can't connect to switch via telnet script(Python3)

    Posted May 15, 2020 03:38 AM

    Hello,
    YA.16.08.0001
    Why not API?
    Because i'm learning Python and want so.



  • 4.  RE: Can't connect to switch via telnet script(Python3)
    Best Answer

    Posted May 15, 2020 04:10 AM

    you can use Python and API !



  • 5.  RE: Can't connect to switch via telnet script(Python3)

    Posted May 15, 2020 05:44 AM
    Ok,I heard you,thanks.

    --
    С уважением,
    Щеголев Глеб Геннадьевич