Python Forum
python telnetlib prompt matching issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python telnetlib prompt matching issue
#1
import unidecode
import telnetlib
import time
import re
from time import sleep
user = 'user'
password = '1234'
with open('eci.txt','r') as ipfile:
    for sr_no, line in enumerate(ipfile, start=1):
        host = line.strip()
        try:
            print ('Connecting .....')+str(host)
            telnet = telnetlib.Telnet(host, 23, 2)
            telnet.read_until('Login :', 3)
            telnet.write(user.encode('ascii') + '\r')
            telnet.read_until('Password :', 3)
            telnet.write(password.encode('ascii') + '\r')
            #telnet.read_until('>')
            telnet.write('bport all' + '\r\r\r\r')
            telnet.read_until("MCR64A >",3)
            telnet.write(' logout''\r')
            output = telnet.read_all()
            print('\x1b[6;30;42m' + 'Success!' + '\x1b[0m')
            print ('printing output.....')
            sleep(2)
            data = iter(output.split('\n'))
        except Exception as excp:
            print(excp)
getting time out, not able to read_until "MCR64A >" prompt, any suggestion.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  telnetlib. configure hostnames lado 1 2,879 May-30-2020, 01:49 PM
Last Post: matya0403
  telnetlib timeout kerzol81 0 3,355 Sep-12-2019, 08:38 AM
Last Post: kerzol81
  Telnetlib reading output petterg 1 11,189 Jul-06-2019, 12:08 PM
Last Post: searching1
  Python script hangs after entering username to remote login using telnetlib auto 0 4,779 Sep-10-2018, 01:10 PM
Last Post: auto
  telnetlib timeout expections handling issue anna 0 7,752 Jun-08-2018, 06:28 AM
Last Post: anna
  telnetlib.Telnet timeout issue.. taking much time anna 1 8,195 Jan-19-2018, 01:52 PM
Last Post: devs4p

Forum Jump:

User Panel Messages

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