Update Mac iCal with Sun Java System Calendar Server events

Export and Import is an easy way to get your Mac iCal up to date. But doing it manually is boring, therefor I thought it would be nice to have this scripted but unfortunately I was not able to create a working applescript for iCal, even the applescript recorder result in empty applescript, don't ask me why. 

My result so far now is a small shell script which export your calendar from the Calendar Server, save it as export.ics and open iCal with the exported.ics file, you only have to click OK for the import.

Note: The script don't take care about hosted domain, but you might get an idea how that need's to look like. In the script itself you need to place the settings for server, username and password. It works for http and https.

#!/bin/sh

# Your calendar server
server="yourserver.domain.tld"

# username and password
user="dummyuser"
pass="mypassword"

curlopts='--silent --insecure'

# Open up a session with the calender server
request="https://${server}/login.wcap?user=${user}&password=${pass}"
id=`curl $curlopts "${request}" | \\
  grep SESSION-ID | head -1 | \\
  sed -e "s/.\*SESSION-ID:\\([a-z,A-Z,0-9]\*\\).\*/\\1/"`
if [ -z "${id}" ]; then
  echo
  echo "Error: Could not get session id!"
  exit 1
fi
printf "\\nSession ID: ${id} - OK\\n" 
printf " - - - - - - - - - \\n"

# export
request="https://${server}/export.wcap"
curl --data "id=${id}&calid=${user}&content-out=text/calendar" "${request}" > ./export.ics

printf "\\n"
printf " - - - - - - - - - \\n"

# logout
request="https://${server}/logout.wcap?id=${id}"
curl $curlopts "${request}"

open export.ics
  
The console output will look like this:
 
$ ./wcap-export.sh 

Session ID: fMLeoJtcMMw - OK
 - - - - - - - - - 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  222k  100  222k    0    53   304k     72 --:--:-- --:--:-- --:--:--  381k

 - - - - - - - - - 
BEGIN:VCALENDAR
PRODID:-//Sun/Calendar Server//EN
METHOD:PUBLISH
VERSION:2.0
X-NSCP-WCAP-ERRNO:-1
END:VCALENDAR
  


Note: If you would update the Sun Java Calendar Server vise versa from iCal then jCalendarCopy might be a solution for you

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Andreas Breuer - TSC Engineer - writes about his life in support.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today