try:
    self.tn = telnetlib.Telnet(ip, 23, TIMEOUT)
except:
    print('Bad Connection')
sys.exit(0)

def run(self):
    e = self.tn.read_until('Login: ')
self.tn.write(USER + '\n')
e = self.tn.read_until('Password: ')
self.tn.write(PASSWORD + '\n')
while True:
    pass
Несколько сеансов telnet Python