wget -O - 'https://USERNAMEHERE:PASSWORDHERE@mail.google.com/mail/feed/atom' --no-check-certificate

Using wget to receive an XML atom feed of your Gmail inbox

I use this command in my Conky script to display the number of messages in my Gmail inbox and to list the from: and subject: fields.
Sample Output
?xml version="1.0" encoding="UTF-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
<title>Gmail - Inbox for patrick.archibald@gmail.com</title>
<tagline>New messages in your Gmail Inbox</tagline>
<fullcount>1</fullcount>
<link rel="alternate" href="http://mail.google.com/mail" type="text/html" />
<modified>2010-09-26T14:39:24Z</modified>
<entry>
<title>Your Order with Amazon.com</title>
<summary>Amazon.com Logo Thanks for your order, Patrick L Archibald! Want to manage your order online? If ...</summary>
<link rel="alternate" href="http://mail.google.com/mail?account_id=patrick.archibald@gmail.com&amp;message_id=12b496e5d987360c&amp;view=conv&amp;extsrc=atom" type="text/html" />
<modified>2010-09-25T15:06:30Z</modified>
<issued>2010-09-25T15:06:30Z</issued>
<id>tag:gmail.google.com,2004:1347868102431815180</id>
<author>
<name>auto-confirm@amazon.</name>
<email>auto-confirm@amazon.com</email>
</author>
</entry>
</feed>

-3
By: PLA
2010-09-26 14:47:13

These Might Interest You

  • this simply curls the feed and runs a xpath query on it ... Show Sample Output


    0
    atomtitles () { curl --silent $1 | xmlstarlet sel -N atom="http://www.w3.org/2005/Atom" -t -m /atom:feed/atom:entry -v atom:title -n}
    Seebi · 2010-12-15 11:03:31 0
  • Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages. For some reason sed gets stuck on OS X, so here's a Perl version for the Mac: curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/' If you want to see the name of the last person, who added a message to the conversation, change the greediness of the operators like this: curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/$2 - $1/' Show Sample Output


    46
    curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
    postrational · 2009-09-07 21:56:40 6

  • 0
    curl -su username:passwd https://mail.google.com/mail/feed/atom | xmlstarlet sel -N x="http://purl.org/atom/ns#" -t -m //x:entry -v 'concat(position(), ":", x:title)' -n
    kev · 2012-05-05 14:34:55 0
  • Copies an entire hierarchy of mailboxes from the named POP3/IMAP/etc. source to the named destination. Mailboxes are created on the destination as needed. NOTE: The 'mailutil' is Washington's University 'mailutil' (apt-get install uw-mailutils). More examples mailutil transfer {imap.gmail.com/ssl/user=you@gmail.com}INBOX Gmail/ ; mailutil check imap.gmail.com/ssl/user=you@gmail.com}\[Gmail\]/Spam If you use the utility in the first, append -v|-d flag(s) to the end the commands above (man mailutil).


    8
    mailutil transfer {imap.gmail.com/ssl/user=john@gmail.com} Gmail/
    bogomips · 2010-10-07 07:30:00 0
  • Checks your gmail account every 30 seconds and display the number of new messages in the top right corner of the terminal. A kind of CLI "Gmail notifier" if you will. :-) This is a mashup of http://www.commandlinefu.com/commands/view/7916/put-a-console-clock-in-top-right-corner and http://www.commandlinefu.com/commands/view/3386/check-your-unread-gmail-from-the-command-line


    0
    while sleep 30; do tput sc;tput cup 0 $(($(tput cols)-15));echo -n " New Emails: $(curl -u username:password --silent https://mail.google.com/mail/feed/atom | grep 'fullcount' | grep -o '[0-9]\+')";tput rc; done &
    saze · 2011-09-07 08:40:28 0
  • Just an alternative with more advanced formating for readability purpose. It now uses colors (too much for me but it's a kind of proof-of-concept), and adjust columns. Show Sample Output


    3
    curl -u username --silent "https://mail.google.com/mail/feed/atom" | awk 'BEGIN{FS="\n";RS="(</entry>\n)?<entry>"}NR!=1{print "\033[1;31m"$9"\033[0;32m ("$10")\033[0m:\t\033[1;33m"$2"\033[0m"}' | sed -e 's,<[^>]*>,,g' | column -t -s $'\t'
    frntn · 2011-10-15 23:15:52 0

What Others Think

For people using funny caracters in their password (such as @ #?or $ ... ) consider using ASCII HEX equivalent to make this work
snaguber · 399 weeks and 4 days ago
how to extract xml data by just hitting the url eg: this is the url http://www.pistonheads.co.uk/xml/news091.asp?c=26 i want to extract the xml data of it.. like PistonHeads (Motoring News) http://www.pistonheads.com/news/ Motoring News Bowler Nemesis Joins Spyker At CPP http://www.pistonheads.com/news/default.asp?storyId=23325 Plans confired for Nemesis EXR road car to be built in Coventry Monday, 14 March 2011 GMT wat is the command to get the xml output from the url ??
planet100 · 375 weeks and 3 days ago
Saw your question Planet100 try using curl, you might need some sed/awk magic, which I cannot help with, but that is a start at least. With curl and some extra effort you could also make the titles clickable links, I think there are other possibly better ways to do it though.
tomjrace · 357 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: