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.)