Q: How can I use a telnet command in Python to check for absence data flow on a remote server I have a remote server with an IP address and a port.  I can connect to it using a standard command window successfully.  When using the command window, I can see data flow through the window but I lack the ability to be notified if the data flow stops.  I would like to use Python instead to accomplish the same task with the added feature of alerting me if/when data flow stops.  I've attached the code that I've been working with below, is anyone able to help me with this process?  
import sys
import telnetlib
import easygui

HOST = "###.###.###.###, 25"

tn = telnetlib.Telnet(HOST)

print tn.read_all()

tn.write("exit\n")

if data =="":
    easygui.msgbox("There's no data!!", title="Bummer Box")


A: The first step is being able to connect to the host; you haven't mentioned if that's working yet.  I believe tn.read_all will keep reading until there's an EOF. You might want tn.expect if you know what the data should look like or perhaps tn.read_lazy if you don't.
The next step is to be able to check the connection on a regular basis, say every minute or every ten seconds.  The threading.Timer will help you schedule the task easily.
The third step is the notification.  If the check for data is successful, just return silently.  Only on the lack of data do you call to pop up a message box, send an email, or whatever.
