#!/usr/bin/python 
import telnetlib 

host = '???'
port = '???'

t = telnetlib.Telnet(host,port)
t.read_until('')
t.write('flush_all\r\n')
t.read_until('')
t.write('quit\r\n')
print t.read_all()