import sys import telnetlib tn = telnetlib.Telnet('localhost') tn.set_debuglevel(2) data = tn.read_until("login: ") print (data) tn.close();