LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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



Reply
 
Search this Thread
Old 04-21-2008, 03:31 PM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 51
Cool gmail: A sort of gmail-notify for the console ?


Hello,

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

I found this but the problem http://reachbeyondgrasp.blogspot.com...-for-dzen.html
is that festival has sound busy, when running it in the crontab...

thanks for any info. or ideas ...

is gmail-notify such unsecured ???
http://www.macosxhints.com/article.p...00707030100345

Last edited by frenchn00b; 04-21-2008 at 05:22 PM.
 
Old 05-13-2008, 05:54 PM   #2
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Original Poster
Rep: Reputation: 51
great ways: http://reachbeyondgrasp.blogspot.com...-for-dzen.html
http://g33k.wordpress.com/2006/07/31...he-python-way/

(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)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUSE Open 10.3. Gmail. PITA. (If you don't have Gmail, you will not understand) Lola Kews Suse/Novell 6 03-19-2008 08:43 AM
Gmail-Notify bjb_nyj101 Linux - Software 3 04-22-2007 05:53 PM
LXer: Import mail into Gmail with the Gmail Loader LXer Syndicated Linux News 0 03-19-2007 07:01 AM
dpkg wont install gmail-notify b/c depends on obselete python package baldy1324 Debian 3 08-11-2006 05:56 PM
Gmail Notify troubles - cannot install xTheLostx Linux - Software 2 05-28-2005 08:18 AM


All times are GMT -5. The time now is 09:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration