Do you know what really grinds my gears. grinds my gears Having to boot Raspberry Pi with a new image on and no HDTV to configure and find the IP in order to ssh to it, and have fun with it. Grrrrrrrrr...

That's when I decided why not create a script, that when the pi boots up it sends me the internal and external IP addresses...

Clever right.

[sourcecode language="bash"]
gedit whats_my_ip.py
[/sourcecode]

copy and paste the following code and don't forget to edit the username, password and address.

[sourcecode language="python"]
import subprocess
import smtplib
import socket
from email.mime.text import MIMEText
import datetime
import urllib2
import time
time.sleep(10)
# Change to your own account information
gmail_user = "***@gmail.com"
gmail_password= "******"
to = "***@gmail.com"
smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_password)
today = datetime.date.today()

arg='ip route list'
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
extipaddr = urllib2.urlopen("http://icanhazip.com").read()
my_ip = 'Local address: %s\nExternal address: %s' % (ipaddr, extipaddr)
msg = MIMEText(my_ip)
msg['Subject'] = 'IP For RaspberryPi on %s' % today.strftime('%b %d %Y')
msg['From'] = gmail_user
msg['To'] = to
smtpserver.sendmail(gmail_user, [to], msg.as_string())
smtpserver.quit()

[/sourcecode]

Now for this to work you need to link the script to /etc/rc.local this will only run it once on reboot.

[sourcecode language="bash"]
python /home/whats_my_ip.py
[/sourcecode]

# More mods are underway