[ale] Need help with a Python Script

Pete Hardie pete.hardie at gmail.com
Thu Nov 17 22:21:31 EST 2011


Would passing the hostname as an argument sole the problem?  It
doesn't get you a python solution, but it might solve the problem


On Thu, Nov 17, 2011 at 21:47, Chuck Payne <terrorpup at gmail.com> wrote:
> 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.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
Pete Hardie
--------
Better Living Through Bitmaps



More information about the Ale mailing list