Skip to content

Instantly share code, notes, and snippets.

@wadouk
Created January 28, 2013 22:39
Show Gist options
  • Save wadouk/4659971 to your computer and use it in GitHub Desktop.
Save wadouk/4659971 to your computer and use it in GitHub Desktop.
Have your raspberry mail it's IP when you plug the network cable. Put in /etc/network/ip-up.d, and chmod +x of course
#!/bin/bash
ip=$(ifconfig | grep "inet addr" | grep -v "127")
/usr/bin/python << EOF 2>&1 >> /tmp/mailip.log
import smtplib
from email.mime.text import MIMEText
msg = MIMEText(" ")
msg['Subject'] = 'Rasp IP %s' % "${ip}"
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP('smtp.known.com')
s.sendmail(me, you, msg.as_string())
s.quit()
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment