Posted on Jan 31, 2011 at 23:45
Services - OpenOffice: Start as a service
This script is useful if you need to run a dedicated OpenOffice service on a system. I had a process that generated PDF files from an OpenOffice template document, which required the OpenOffice service to be running on the system at all times. So I setup this script and created a cronjob for it, which ran every morning to make sure the service was always up and functioning properly. Incidently, this script was setup to run in a cygwin environment.
|Script snippet that checks to see if service is running:|
CHECK=`/cygdrive/c/Windows/system32/netstat -anpo tcp | grep 127.0.0.1:8100`;
Here we are using netstat to see if the process is running. This command can be broken down as follows: -anpo tcp: This tells netstat to display the state of all sockets [a], show network addresses as numbers [n], show only connections for the protocol specified, tcp in this case [p] and display the owning process ID [o]. grep 127.0.0.1:8100: This piece grabs any process running on port 8100, the port the OpenOffice service runs on, and assigns it to the CHECK variable.
|Start-up command for OpenOffice service in script:|
/cygdrive/c/Program\ Files\ \(x86\)/OpenOffice.org\ 3/program/soffice -accept="socket,port=8100;urp;StarOffice.ServiceManager"
This line starts the service. It starts it on port 8100, which is the standard port for OpenOffice.