Skip to content

Instantly share code, notes, and snippets.

@blister
Created June 2, 2010 13:55
Show Gist options
  • Select an option

  • Save blister/422395 to your computer and use it in GitHub Desktop.

Select an option

Save blister/422395 to your computer and use it in GitHub Desktop.
#!/bin/bash
# this is the script you would use for generic GMail addresses..
echo "[email protected]"
echo "--------------------"
curl -u [email protected]:YOUR_PASSWORD --silent "https://mail.google.com/mail/feed/atom" | perl -ne \
'
print "Message Count: $1 \n\n" if /<fullcount>(.+?)<\/fullcount>/;
print (($title - 1) . ". $1 ") if /<title>(.+?)<\/title>/ && $title++;
print "(from $1)\n" if /<email>(.+?)<\/email>/;
'
#!/bin/bash
# this is the script you would use for Google Apps based email addresses.
echo "your_email@your_domain.com"
echo "--------------------------"
curl -u your_email@your_domain.com:YOUR_PASSWORD --silent "https://mail.google.com/a/your_domain.com/feed/atom" | perl -ne \
'
print "Message Count: $1 \n\n" if /<fullcount>(.+?)<\/fullcount>/;
print (($title - 1) . ". $1 ") if /<title>(.+?)<\/title>/ && $title++;
print "(from $1)\n" if /<email>(.+?)<\/email>/;
'
@blister
Copy link
Author

blister commented Jun 2, 2010

If you want to make this a little bit more secure and don't like having your account passwords stored in the file, take out the :YOUR_PASSWORD and this script will prompt you for your password every time you run it.

@jmhobbs
Copy link

jmhobbs commented Jun 2, 2010

Nice! I didn't know that GMail provided an atom feed, very handy.

@blister
Copy link
Author

blister commented Jun 2, 2010

Yeah, I was amazed as well. I found this technique in an article on 10 Useful Commandline One-Liners. I made a bunch of tweaks to their style and decided to store my password in the script so that I don't have to keep typing it every time (I run the code on my server, and if that gets hacked, I'm basically screwed anyway... so meh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment