Home > Web > Get number of unread posts from google mail

Get number of unread posts from google mail

November 1st, 2009 Ed Leave a comment Go to comments

Here’s a simple bash script that gets the number of unread messages, and runs a command that does something with that. In my case, a java program that puts a message on a MQTT topic, which indirectly flashes an ambient light.

#!/bin/bash
while (true)
do

rm atom
rm atom_process

wget https://gmail.google.com/gmail/feed/atom --user=XXXXX --password=XXXXX 2&>1  /dev/null

cat atom | grep fullcount > atom_process
count=`sed -n -e 's/.*>\(.*\)<.*/\1/p' atom_process`

java -jar /home/ed/rrd/MQTTRunner.jar mpc_google 3 $count
sleep 60

done

Categories: Web Tags: ,