#!/usr/bin/bash

# crontab entry
#00 05 * * *     ~/bin/start_ooffice.sh

#OOFFICE="/cygdrive/c/Program\ Files\ \(x86\)/OpenOffice.org 3/program/soffice";

# Start OpenOffice.org in listening mode on TCP port 8100. 
#$OOFFICE "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -norestore -nofirststartwizard -nologo -hea
dless & 
CHECK=`/cygdrive/c/Windows/system32/netstat -anpo tcp | grep 127.0.0.1:8100`;
echo $CHECK

if [ ! "$CHECK" ] 
then 
        echo "Starting OpenOffice Service" 
/cygdrive/c/Program\ Files\ \(x86\)/OpenOffice.org\ 3/program/soffice -accept="socket,port=8100;urp;StarOffice.ServiceManager
"
        # Wait a few seconds to be sure it has started. 
        sleep 5s 
fi

exit

