[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Need help with a Python Script
- Subject: [ale] Need help with a Python Script
- From: terrorpup at gmail.com (Chuck Payne)
- Date: Thu, 17 Nov 2011 21:47:02 -0500
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.