Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there a sort of gmail-notify for the console for the user crontab -e ?
then I want that the crontab every 5 min, say with festival the subject and from of the received gmail emails
(one need python feed parser / and for perl depndng on)
Modified version of rajajs's to show the last email only:
Code:
#!/usr/bin/env python
#========================================================================
# Copyright 2007 Raja <rajajs@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#==========================================================================
# ======================================================================
# Modified from code originally written by Baishampayan Ghose
# Copyright (C) 2006 Baishampayan Ghose <b.ghose@ubuntu.com>
# ======================================================================
import urllib
import feedparser
_url = "https://mail.google.com/gmail/feed/atom"
################## Edit here #######################
#pwd = xxxx # pwd stored in script
_pwdfile = '/folder/folder2/pwd' # pwd stored in a file
_username = 'USERNAME'
_calmcolor = 'white'
_alertcolor = 'red'
_maxmails = 1 # maximum new mails to show
_maxwords = 8 # maximum words to show in each mail header
###########################################################
class GmailRSSOpener(urllib.FancyURLopener):
'''Logs on with stored password and username
Password is stored in a hidden file in the home folder'''
def prompt_user_passwd(self, host, realm):
#uncomment line below if password directly entered in script.
pwd = open(_pwdfile).read()
return (_username, pwd)
def auth():
'''The method to do HTTPBasicAuthentication'''
opener = GmailRSSOpener()
f = opener.open(_url)
feed = f.read()
return feed
def showmail(feed):
'''Parse the Atom feed and print a summary'''
atom = feedparser.parse(feed)
newmails = len(atom.entries)
# if newmails == 0:
# title = "^fg(%s) You have no new mails" % (_calmcolor)
# elif newmails == 1:
# title = "^fg(%s) You have 1 new mail" % (_alertcolor)
# else:
# title = "^fg(%s) You have %s new mails" % (_alertcolor,newmails)
# print the title with formatting
# print "^tw()" +title
#clear the slave window
# print "^cs()"
#then print the messages
for i in range(min(_maxmails,newmails)):
emailtitle = atom.entries[i].title
# show only first few words if title is too long
if len(emailtitle.split()) > _maxwords:
emailtitle = ' '.join(emailtitle.split()[:_maxwords])
# print "from %s" % (atom.entries[i].author)
# print "%d" % (i)
print "author= %s" % (atom.entries[0].author)
print "title= %s" % (atom.entries[0].title)
print "summary= %s" % (atom.entries[0].summary)
#emailtitle
if __name__ == "__main__":
feed = auth()
showmail(feed)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.