3 wget -O /tmp/calendar.$$.ics https://calendar.google.com/calendar/ical/adefaria%40gmail.com/public/basic.ics > /tmp/updateCalendar.$$.log 2>&1
4 wget -O /tmp/meetups.$$.ics 'http://www.meetup.com/events/ical/10426135/8dfdd0ffaaedecf720c5faf0cf3871b7ee5f5c1e/going' >> /tmp/updateCalendar.$$.log 2>&1
5 wget -4 -O /tmp/tripit.$$.ics 'http://www.tripit.com/feed/ical/private/06C4F90D-EFEFB9C5FDB17EC5FCB327DE31A54D96/tripit.ics' >> /tmp/updateCalendar.$$.log 2>&1
7 # Now let's combine the files. First strip off the END:CALENDAR from the main
9 filesize=$(wc -l /tmp/calendar.$$.ics | cut -f1 -d' ')
11 head -n $lines /tmp/calendar.$$.ics > /tmp/calendar2.$$.ics
12 mv /tmp/calendar2.$$.ics /tmp/calendar.$$.ics
14 # Now extract the middle of the next calendar
15 # Note, if we have nothing RSVPed here for Meetup then the file should be skipped.
16 # We will get an .ics file but it'll be short - less than 27 lines
17 filesize=$(wc -l /tmp/meetups.$$.ics | cut -f1 -d' ')
19 if [ $filesize -gt 27 ]; then
22 # Get the top portion...
23 tail -n $lines /tmp/meetups.$$.ics > /tmp/meetups2.$$.ics
25 # Now strip off END:VCALENDAR
26 let lines=filesize-27-1
28 head -n $lines /tmp/meetups2.$$.ics >> /tmp/calendar.$$.ics
31 rm -f /tmp/meetups2.$$.ics
34 # Now extract the middle of the next calendar
35 filesize=$(wc -l /tmp/tripit.$$.ics | cut -f1 -d' ')
37 if [ $filesize -gt 27 ]; then
40 # Get the top portion...
41 tail -n $lines /tmp/tripit.$$.ics > /tmp/tripit2.$$.ics
43 # Now strip off END:VCALENDAR
44 let lines=filesize-27-1
46 head -n $lines /tmp/tripit2.$$.ics >> /tmp/calendar.$$.ics
49 rm -f /tmp/tripit2.$$.ics
52 # Now add END:VCALENDAR to calendar.ics
53 echo "END:VCALENDAR" >> /tmp/calendar.$$.ics
56 mv /tmp/calendar.$$.ics ~/Documents/calendar.ics
58 # Get rid of stupid CRs
59 dos2unix -q ~/Documents/calendar.ics
64 rainlendar2 > /tmp/rainlendar2.log 2>&1 &
70 /tmp/updateCalendar.$$.log