Showing posts with label sms. Show all posts
Showing posts with label sms. Show all posts

01 April 2011

Never Forget Your Home IP Address Again!! Python Saves The Day

I have a Linux workstation located at a friend's house that I need to use throughout the day via SSH but I kept forgetting the IP address. He has a dynamic IP address and I didn't feel the need to use a service like dyndns so I wrote a simple Python script that sends a text message to my cell phone each morning at 5:00am. It's quite simple and works great. I hope you find it useful.
#!/usr/bin/env python
import httplib2
import smtplib

h = httplib2.Http(".cache")
res, content = h.request("http://www.whatismyip.com/automation/n09230945.asp", "GET")

s = smtplib.SMTP('smtp.gmail.com:587')
s.starttls()
s.login("username@gmail.com", "password")
s.sendmail("Me", "6025551212\@tmomail.net", content)
s.quit()
Just replace the username, password, and destination email-to-sms gateway for your cell phone carrier.