Python Forum
telnet stuck when get Press any key to continue
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
telnet stuck when get Press any key to continue
#2
Hi There,

Manage to previous issue, however, telnet timeout taking too much time. what could be the issue?

#!/usr/bin/python
import paramiko
import sys
import os
import xlrd
import unidecode
import telnetlib
import time

def telNetConnection(column1,column2,column3):
 host = [ (column1),]
 for host in host:
  print 'Processing'+' '+column1
  user  = (column2)
  password = (column3)
  telnet  = telnetlib.Telnet(host,23,2)
  telnet.read_until('User name:',3)
  telnet.write(user.encode('ascii') + '\r')
  telnet.read_until('Password:',3)
  telnet.write(password.encode('ascii') + '\r')
  #telnet.read_until('>',3)
  telnet.write('statistics mac 1~48' + '\r\r\r')
  #telnet.read_until("    Press any key to continue, 'e' to exit, 'n' for nopause")
  #telnet.write('n')
  telnet.read_until('>',3)
  telnet.write('exit' + '\r')
  output=telnet.read_all()
  f = open('macportdetail.txt', 'w')
  f.write(host+" "+str(output))


os.chdir("/home/anna/scripts")
workbook = xlrd.open_workbook('zyxeldslams.xlsx')
worksheet = workbook.sheet_by_name('Sheet1')

#try:
for x in range(1,375):
    column1 = (worksheet.cell(x,0).value).decode('ascii')
    column2 = (worksheet.cell(x,1).value).decode('ascii')
    column3 = str(worksheet.cell(x,2).value).decode('utf-8')
    try:
        telNetConnection(column1,column2,column3)
    except:
         print "Connection time out"
         pass
Reply


Messages In This Thread
RE: telnet stuck when get Press any key to continue - by anna - Dec-30-2017, 03:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Telnet command in Python 3.9 Dre83 0 2,039 Nov-11-2020, 11:42 AM
Last Post: Dre83
  Sending command using telnet mradovan1208 1 4,115 Apr-24-2020, 07:09 PM
Last Post: Larz60+
  Press a botton to continue the code doug2019 1 1,961 Nov-18-2019, 09:38 AM
Last Post: Gribouillis
  Serial to telnet using Python Charles_Linquist 2 6,343 Jun-17-2019, 04:37 PM
Last Post: DeaD_EyE
  Multi thread telnet issue anna 0 2,230 Mar-29-2018, 05:35 PM
Last Post: anna
  telnet unexpected output printing anna 3 3,672 Jan-17-2018, 01:16 PM
Last Post: anna
  help required to parsing telnet output anna 8 8,679 Jan-12-2018, 11:05 AM
Last Post: anna

Forum Jump:

User Panel Messages

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