[ale] Need help with a Python Script
Chuck Payne
terrorpup at gmail.com
Thu Nov 17 21:47:02 EST 2011
Guys,
I need a mentor. I am trying to teach myself Python. I need to create
a few script to monitor my servers. But I am having issue with the
e-mail part of my script
What I want it to do it send me alert with the host name in the
Subject and Body, but I am either getting syntax error or when it does
work I get None. How can I pass the hostname?
Here my script
=============start script=============
#!/usr/bin/python
import os, smtplib
system_name = os.getenv('HOSTNAME')
SERVER = localhost
FROM = "me at abc.com"
TO = ["you at nbc.com"]
SUBJECT = "Mail from",os.getenv('HOSTNAME')
TEXT = "This message is from",os.getenv('HOSTNAME')
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send message
server = smtplib.STMP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()
=============end script=============
--
(678) 636-9678
-----------------------------------------
Discover it! Enjoy it! Share it! openSUSE Linux.
-----------------------------------------
openSUSE -- en.opensuse.org/User:Terrorpup
openSUSE Ambassador/openSUSE Member
skype,twiiter,identica,friendfeed -- terrorpup
freenode(irc) --terrorpup/lupinstein
Register Linux Userid: 155363
Have you tried SUSE Studio? Need to create a Live CD, an app you want
to package and distribute , or create your own linux distro. Give SUSE
Studio a try. www.susestudio.com.
More information about the Ale
mailing list