telnetlib other ways to press Enter , can't proceed with script when a server is just booted up

I run python script using telnetlib on linux virtual machine.

99% of the time, tn.write('\n') works smoothly.

But there's a case when a server is just booted up, in the real console, first user logged in needs to press Enter on the keyboard after seeing the login information to proceed. If they don't press Enter, they will stay with the login information forever.

And this time tn.write('\n') doesn't work simply same as manually press Enter in the console. Even not the ways to press Enter using script below:

tn.write('\r\n')
tn.write("\r\n".encode('ascii'))

# or with time.sleep(1) inserted with any value

My script can connect to the server with password, just like every time.

By using read_some or read_eager, I'm pretty sure that there's(my script encounters) only a table of information on the console, no prompt, no indication to ask user press Enter, just if you press Enter you go into the console and get your first prompt.

(If I manually log in, press Enter and exit, my script runs smoothly as it's not the first user anymore.)

Answers


Try calling for debug, I generally use this in the begin:

tn = telnetlib.Telnet(ip_to_connect)

tn.set_debuglevel(5)

This helps me get what the console is returning, when its an ASCII console, you will get something like: '\xff\xfb\x01\xff\xfb\x03\xff\xfd\x18\r\n' and it's possible to use this information in read.until()


Need Your Help

Syntax error in INSERT INTO statement. System.Data.OleDb.OleDbErrorCollection

asp.net database webforms ms-access-2010

Hi I am creating basic form in Visual Studio 2012 Express. I am using Microsoft Access 2012 as database. My problem is when I press submit button I nothing happens.