As I was sitting at my desk at work, watching code roll by as my Monte Carlo runs worked, I thought about how nice it would be to go do something else while I waited for data.  An email notifier wouldn’t be enough, as I might want to be away from wifi.  Then I remembered that Bell has an email to text message gateway, .  In the course of ~10 minutes, I was able to whip up a python script that will send me a short email notifying me that my jobs have completed.  All I have to do is add a line at the end of a script with the python script and the job name, and it will send me a message as soon as the script run completes.  I simply store the password for my local smtp server in ~/.pass, and it fires of texts like magic.  Python makes everything easy.  Code after the jump.


import sys
import smtplib

if __name__ == "__main__":
	pwd = open("~/.pass").readline()[:-1]
	toaddr = ""
	fromaddr = "username@smtpserver"
	msg = "Job "+sys.argv[1]+" is done"
	server = smtplib.SMTP('smtpserver')
	server.login('username', pwd)
	server.sendmail(fromaddr, toaddr, msg)