Created
March 29, 2018 22:10
-
-
Save aurorapar/1c567356062e29a3b865d943d695ce5e to your computer and use it in GitHub Desktop.
Email IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import smtplib for the actual sending function | |
import smtplib, sys, os | |
# Import the email modules we'll need | |
from email.mime.text import MIMEText | |
MY_ADDRESS = '[email protected]' | |
PASSWORD = '<EMAIL PASSWORD>' | |
message = 'Your network settings are: ' | |
for x in sys.argv: | |
if x != sys.argv[0]: | |
message += x + ' ' | |
msg = MIMEText(message) | |
# me == the sender's email address | |
# you == the recipient's email address | |
msg['Subject'] = 'Raspberry Connection Info' | |
msg['From'] = MY_ADDRESS | |
msg['To'] = MY_ADDRESS | |
# Send the message via our own SMTP server, but don't include the | |
# envelope header. | |
s = smtplib.SMTP(host='smtp.gmail.com', port=587) | |
s.ehlo() | |
s.starttls() | |
s.login(MY_ADDRESS, PASSWORD) | |
s.sendmail(msg['From'], msg['To'], msg.as_string()) | |
s.quit() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ip=`ifconfig wlan0` | |
python emailip.py $ip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
allow-hotplug wlan0 | |
iface wlan0 inet dhcp | |
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf | |
iface default inet dhcp | |
post-up /home/pi/emailip.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment