Tuesday, March 25, 2008

Checking RoundCube webmails from console

I wrote this script to check "Today's" new email for the webmail account I have with NICTA, as obviously opening a new browser window, logging in and checking emails every hour was becoming a pain in the neck ... and ya, of course for the reason too, that konsole is more fun ;) ...


#!/bin/bash

read -s -p "enter password: " pass
echo

curl -s -k -c nicta.cookie -d "_action=login&_user=NICTA%2FXXX%2FYYY.ZZZ&_pass=$pass" 'https://webmail.nicta.com.au/' -L 2>&1 1>/dev/null

curl -s -k -b nicta.cookie -d "_action=login&_user=NICTA%2FXXX%2FYYY.ZZZ&_pass=$pass" "https://webmail.nicta.com.au/" -L -o - | grep "Today " | sed -e :a -e "s/Today/`date +%d:%m:%y`/g;s/ \;//g;s/<[^>]*>//g;/<;/N;//ba" | awk '{print $2}' rm nicta.cookie

** The script could be made more fancier, some IF/ELSE in the proper place should do the trick. I'll finish the script soon as I find some free time.