Hi all,
I'm a noobie at shell scripting (and Linux) with no experience on programing.
I'm trying to create a script that will download my xml calendar from Google, process it in the [month, day<TAB>description] format and dump it into $HOME/.calendar/calendar.
Eg:
April 10 Event
I'm having a hard time using field delimiter on
cut because the xml code changes depending on how much info I have on that calendar entry.
Here's an example of an entry in xml:
Quote:
<br />Event Status: confirmed</content><link rel='alternate' type='text/html' href='http://www.google.com/calendar/event?eid=aXY2MW1vY2sxOTNiYnQ5aG5qczlxaXNscjQgdmljdG9yYnJjYUBt' title='alternate'/><link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/xxxxxxxgmail.com/public/basic/iv61mock193bbt9hnjs9qislr4'/><author><name>xxxxxx xxxxxxx</name><email>xxxxxxx@gmail.com</email></author></entry><entry><id>http://www.google.com/calendar/feeds/xxxxxxxxxxxxxgmail.com/public/basic/h40hv3rhht360l0sp36ctr2ef8</id><published>2008-09-23T02:48:41.000Z</published><updated>2008-09-23T02:48:41.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'/><title type='html'>Flooring</title><summary type='html'>When: Mon Sep 29, 2008<br>
<br>Event Status: confirmed</summary><content type='html'>When: Mon Sep 29, 2008<br />
|
This the script I came up with:
Code:
#!/bin/bash
## Reads URL
_url=$1
## Gets Title
_get1=`wget $_url -q -O - | cut -d">" -f20 | grep title | sed 's/..title//g'`
## Gets time
_get2=`wget $_url -q -O - | cut -d">" -f3 | egrep '^W' | cut -d" " -f3,4 | sed 's/,//g'`
#Counter
_cnt=`echo "$_get1" | wc -l`
_cnt=$(( _cnt + 1 ))
#echo $_cnt
e="1"
while [ "$e" -lt "$_cnt" ] ; do
_title=`echo "$_get1" | head -n "$e" | tail -n 1`
_time=`echo "$_get2" | head -n "$e" | tail -n 1`
# echo -e "$_time\t$_title"
# echo "$e"
e=$(( e + 1 ))
done