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.

1 comment:

  1. Hi friends,

    The biggest advantages of Dynamic IP Addressing are less security risk as the computer is assigned a new IP address each time the customer logs on, they are cost effective and there is automatic network configuration. Dynamic addressing is usually used by ISP's so that one IP address can be assigned to several users. Thanks a lot.....

    Web Harvester

    ReplyDelete