Created
February 20, 2015 14:24
-
-
Save tangblack/239465bcf289145ab847 to your computer and use it in GitHub Desktop.
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
#!/usr/local/bin/python | |
import commands | |
def getIpList(): | |
ipList = commands.getoutput("/sbin/ifconfig | grep -i \"inet\" | grep -iv \"inet6\" | " + | |
"awk {'print $2'} | sed -ne 's/addr\:/ /p'") | |
return ipList | |
import smtplib | |
def sendViaGmail(title, message): | |
fromaddr = '[email protected]' | |
toaddrs = '[email protected]' | |
msg = "\r\n".join([ | |
"From: [email protected]", | |
"To: [email protected]", | |
"Subject: " + title, | |
"", | |
message | |
]) | |
username = '[email protected]' | |
password = 'your_gmail_password' | |
server = smtplib.SMTP('smtp.gmail.com:587') | |
server.ehlo() | |
server.starttls() | |
server.login(username,password) | |
server.sendmail(fromaddr, toaddrs, msg) | |
server.quit() | |
import socket | |
message = socket.gethostname() + ":\n" + getIpList() | |
title = socket.gethostname() + " wake up now" | |
print "Sending mail..." | |
sendViaGmail(title, message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment