菜单

using openoffice headless ( macro, shell, php )

2011年03月27日 - linux

here is a very simple script to run openoffice headless.
it works on a debian sarge, you have to do this before :
# apt-get update && apt-get install xvfb

here is the code :

Code:
#!/bin/bash

echo ———–DEBUT
date

export PATH=$PATH:/usr/bin/X11
export LANG=fr_FR
export HOME=/var/www

xvfb-run -a /usr/bin/openoffice -invisible “macro:///Library.module1.go($1)”

date

it runs a macro with openoffice as the www-data user.
u have to prepare macro before.
see that u can pass a parameter to the macro via the shell script.

i call the shell script from a php script that looks like this :

Code:
// appeler ooo
$cmd=(“/path/to/script.sh argument  > /dev/null 2>&1”);
exec($cmd);

echo and date are usefull for degugging the shell script before calling it from php.

i use those scripts in a web application. ooo is in charge of generating pdf files.

发表评论

电子邮件地址不会被公开。 必填项已用*标注