OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

using openoffice headless ( macro, shell, php )
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
elehenaff
Power User
Power User


Joined: 16 Apr 2004
Posts: 76
Location: paris - france

PostPosted: Tue Aug 24, 2004 4:45 am    Post subject: using openoffice headless ( macro, shell, php ) Reply with quote

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.

regards
Back to top
View user's profile Send private message Visit poster's website
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Aug 25, 2004 12:24 am    Post subject: Reply with quote

what is xvfb tool ?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
elehenaff
Power User
Power User


Joined: 16 Apr 2004
Posts: 76
Location: paris - france

PostPosted: Wed Aug 25, 2004 2:15 am    Post subject: Reply with quote

xvfb means X virtual frame buffer.
http://packages.debian.org/testing/x11/xvfb

Quote:

Package: xvfb (4.3.0.dfsg.1-4)
virtual framebuffer X server

xvfb provides an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory. The primary use of this server was intended to be server testing, but other novel uses for it have been found, including testing clients against unusual depths and screen configurations, doing batch processing with Xvfb as a background rendering engine, load testing, as an aid to porting the X server to a new platform, and providing an unobtrusive way to run applications that don't really need an X server but insist on having one anyway.

This package also contains a convenience script called xvfb-run which simplifies the automated execution of X clients in a virtual server environment. This convenience script requires the use of the xauth program from xbase-clients, hence the suggestion of xbase-clients.


ooo cant run without an x server. what i wanted was to use ooo as a pdf generating server. no user interface is needed.
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Thu Aug 26, 2004 6:25 am    Post subject: Reply with quote

That's a very concise example. Especially using "xvfb-run".

I'm just adding a cross reference to some other related material.


Discussion of setting up OOo/user folder, and/or running OOo as a particular user instead of root.....
http://www.oooforum.org/forum/viewtopic.php?p=45970#45970


Other related links....


X-Windows and headless
======================

OpenOffice at boot time?
Be sure that you've set up your OOo folder in home directory
when running OOo from a boot script.
http://www.oooforum.org/forum/viewtopic.php?t=11265

using openoffice headless ( macro, shell, php )
This example uses Xvfb, and includes link to explanation
of what Xvfb is.
http://www.oooforum.org/forum/viewtopic.php?t=11890

http://www.oooforum.org/forum/viewtopic.php?t=4975

http://www.oooforum.org/forum/viewtopic.php?t=3600
http://www.oooforum.org/forum/viewtopic.php?t=2986
http://www.oooforum.org/forum/viewtopic.php?t=2977
http://www.oooforum.org/forum/viewtopic.php?t=2707
http://www.oooforum.org/forum/viewtopic.php?t=2403

http://www.oooforum.org/forum/viewtopic.php?t=4193

http://www.oooforum.org/forum/viewtopic.php?t=3929

http://www.oooforum.org/forum/viewtopic.php?t=6322

See "The Office Headless Mode" at this site...
http://framework.openoffice.org/servlets/ProjectDocumentList?folderID=151

Running second X session
http://www.oooforum.org/forum/viewtopic.php?p=21046#21046

Discussion of headless on XVfb on Solaris
http://www.oooforum.org/forum/viewtopic.php?t=5095
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
jbotte
Power User
Power User


Joined: 27 Jan 2004
Posts: 57
Location: NC, USA

PostPosted: Wed Oct 06, 2004 10:55 am    Post subject: More "headless" references... Reply with quote

If you want to run "headless" you can also check out:

Linux: Automated OOo User Installation

which describes a complete framework for doing "headless" installation (including running the Xvfb at startup and dynamically for a specific operation), and:

Comprehensive MailMerge for Flat Files

which is a macro package that is intended for "headless" operation on a remote server (or local workstation, invoked programatically rather than interactively). I will also be posting, relatively soon, a system for managing console I/O from a Basic macro as well as stateful operation and error reporting even when multiple OOo sessions are open by the same user on the same workstation (I'll update this post with a link to it when it's done).
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Sat Dec 18, 2004 10:07 am    Post subject: Re: using openoffice headless ( macro, shell, php ) Reply with quote

elehenaff wrote:
here is a very simple script to run openoffice headless.

Regarding at least OOo 1.1.2 and 1.1.3, OOo still shows a dialog in headless mode, if it stumbles over an internal error: The crash report. And that's bad, because it's a little difficult to klick a dialog box inside Xvfb Wink

Studying the OOo source code, I found a solution: The crash report determines BEFORE he shows the dialog, to which server he has to send the crash report. And if he can't find one, he doesn't display the annoying dialog. All you have to do is open "bootstrap.ini" (on Windows) or "bootstraprc" (on Solaris/Linux) and delete the ErrorReportServer.

At the end of "bootstrap*" you find this lines:
Code:
[ErrorReport]
ErrorReportPort=80
ErrorReportServer=report.services.openoffice.org

Simply change them to
Code:
[ErrorReport]
ErrorReportPort=80
ErrorReportServer=

and no crash report will bother you any longer. You find the "bootstrap*" files in the "program" folder of your OpenOffice.org installation folder.

I definitly don't understand why the crash report isn't disabled with "-headless". But the above worked for me.

With kind regards
hol.sten
Back to top
View user's profile Send private message
unsavory
General User
General User


Joined: 26 Mar 2006
Posts: 7

PostPosted: Sun Mar 26, 2006 10:41 am    Post subject: Reply with quote

This may be a little OT, but does anyone know how I can get xvfb-run? We're running CentOs 4.3 and apparently the Xvfb that is packed with it does not include xvfb-run.

Thanks!
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Sun Mar 26, 2006 11:02 am    Post subject: Reply with quote

unsavory wrote:
This may be a little OT, but does anyone know how I can get xvfb-run? We're running CentOs 4.3 and apparently the Xvfb that is packed with it does not include xvfb-run.

You have a package named "Xvfb" available? Look for a tool called "Xvfb". That may suffice. I wrote in this thread http://www.oooforum.org/forum/viewtopic.phtml?t=33890&highlight=xvfb (take a closer look at the forth post) how you can start OOo from a script with xvfb on a *nix system.

With kind regards
hol.sten
Back to top
View user's profile Send private message
bikram
General User
General User


Joined: 23 Aug 2006
Posts: 7

PostPosted: Wed Aug 23, 2006 10:08 pm    Post subject: simple solution. PDF and Conversion needs SWX ODT DOC XLS Reply with quote

I have sucessfully run openoffice from terminal -- PUTTY

on ooffice 1.1.3 FC3 and 2.0 FC5 (FC= Fedora Core)

first frame buffer

1) Xvfb :5 -screen 0 800x600x16 &

2) ooffice -invisible -nologo -display :5 -headless and what command u want to run

when this is run from putty does a beautiful job.....

but if i run from php..... nothing happens....

even the script calling didnt help

#!/bin/bash
ooffice -invisible -nologo -display :5 -headless

the exec(), system(), parse..... none came to the rescue....

as i am a admin not a developer.... i took my way... the solution not in php but in system...

after 7 day of fight day n night... left and right... here n there..... fidling with ooffice and its execuitables ......

ofcource some helep from this forum tooo.. Wink (BIG THANX for that)

ouch.... came the result...... 3 lines.... thats all...

the findings r...

when run by apache / php / u login as apache.... a use who has no login rights...

therefore nothing to do with system.. Sad

no home, no path, no login permissions.... etc .. etc...

so i modified the script...

export HOME=/tmp
PATH=$PATH:/bin:/usr/bin/:
export PATH
export TEMP=/tmp

ooffice -invisible -nologo -display :5 -headless

PS... /tmp is chmod 777 world writable readable and execuatable

and work done dona done done .....

OUTPUS STARTING TO COME...... tried

-p for printing >> Successfull....

running macros for conversion......

ooffice -invisible -nologo -display :5 -headless "macro:///Standard.Module1.ConvertToPDF(full path to DOC, TXT, RTF, SWX, ODT, XLS ETC )"


Then .... what was my motive.... to get a PDF out put. which frees me of all the compatiability issues caused by different versions and types of offices.... so.......

so... I did a smart thing....

I installed cups-pdf printer..... u can find this here.... aproxx for all distributions customized downloads...
http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/download.shtml


and that worked like charm....

ooffice -invisible -nologo -display :5 -headless -p /full/path/tp/file with extension

this worked great ..... SUPER GREAT

now i am able to print to pdf...

MS DOCS..... 97/2000/XP/2003
MS EXCEL .... 97/2000/XP/2003
All openoffice Docs
HTML files.....
RTFs........

what more......

I shared this linux pdf printer and now My whole office is Printing to pdf.......

made a site and php...... (OFCOURCE... the developers did that on my IDEA... remember i am a System Admin not a developer) my Branch offices now.... Uploads their docs and XLS and ODT ansd SWX files and ooffice converts it to pdf and further those r send by mail to respective departments.... Smile

This all eliminates the need of installind MS OFFICE and OOFFICE for compatiablity reasons....

We can now use what ever choice and version of office/openoffice we want and share the PDF Universally any where... irrespective of what the version and liking of office the reader is having....

REMEMBER OPEN SOURCE AND OPEN WILL

I gota a raise because of all this.... Very Happy


Thanx for the tips i got from all u people here....

So in return i am sharing this to help other get their raise.... Wink

thanx a zellions for all the help and

I BOW MY HEAD TO OPENOFFICE TEAM......

SUCH A GREAT SOLUTION AND THAT TO FREE.........
NOT EVEN A SINGLE PENNY I SPENT... BUT SAVED A FORTUNE IN RETURN......

THANX AGAIN...... Embarassed Embarassed
Back to top
View user's profile Send private message Yahoo Messenger
AndrewZ
Moderator
Moderator


Joined: 21 Jun 2004
Posts: 4140
Location: Colorado, USA

PostPosted: Wed Feb 27, 2008 3:07 pm    Post subject: Re: simple solution. PDF and Conversion needs SWX ODT DOC XL Reply with quote

bikram wrote:
1) Xvfb :5 -screen 0 800x600x16 &


For the record, OpenOffice.org 2.3.0+ Linux no longer requires an X server (not even Xvfb) if you install the headless RPM package and use the -headless option.

Some people may be interested in the article Batch command line file conversion with PyODConverter which shows how to use both -headless and Xvfb, so you can choose the one you prefer.
_________________
<signature>
* Did you solve your problem? Do others a favor: Post the solution
* OpenOffice.org Ninja
* BleachBit
</signature>
Back to top
View user's profile Send private message Visit poster's website
elehenaff
Power User
Power User


Joined: 16 Apr 2004
Posts: 76
Location: paris - france

PostPosted: Thu Feb 28, 2008 3:06 am    Post subject: Reply with quote

That is really good news. openOffice.org developpers keep on imroving their software every day. thanks to them.
the next great evolution will be the odf toolkit to build server software really without the UI. i'm looking forward to it.
_________________
my box : ooo 2.4 french on winXPSP2
my home : ooo 3.0 beta on winXP
server : ooo 1.1.2 on a debian sarge box using ooo as a pdf generator for a web software
workstations : 150 windows XP workstations with ooo 2.4
Back to top
View user's profile Send private message Visit poster's website
ponkeymeat
Newbie
Newbie


Joined: 15 Apr 2008
Posts: 2

PostPosted: Tue Apr 15, 2008 8:38 am    Post subject: Headless option / Openoffice as service Reply with quote

# unset DISPLAY
# ./soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

I use the above commands but I keep getting the below error:

/usr/lib/openoffice.org/program/soffice.bin X11 error: Can't open display:
Set DISPLAY environment variable, use -display option
or check permissions of your X-Server
(See "man X" resp. "man xhost" for details)

I'm running Fedora 8. Currently using Putty.

Since it's running as headless I wouldn't think you would need Xvfb installed, which it's not. Can someone let me know something/anything I can try.?? Mad
Back to top
View user's profile Send private message
AndrewZ
Moderator
Moderator


Joined: 21 Jun 2004
Posts: 4140
Location: Colorado, USA

PostPosted: Tue Apr 15, 2008 9:05 am    Post subject: Reply with quote

Ponkeymeat,
1. Did you install the headless RPM?
2. Use the -headless command line option
_________________
<signature>
* Did you solve your problem? Do others a favor: Post the solution
* OpenOffice.org Ninja
* BleachBit
</signature>
Back to top
View user's profile Send private message Visit poster's website
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Tue Apr 15, 2008 9:49 am    Post subject: Re: Headless option / Openoffice as service Reply with quote

ponkeymeat wrote:
/usr/lib/openoffice.org/program/soffice.bin X11 error: Can't open display:
Set DISPLAY environment variable, use -display option

It seems that you're not using the real headless support http://blogs.linux.ie/caolan/2007/05/04/headless-ooo/
Or try this thread: http://user.services.openoffice.org/en/forum/viewtopic.php?f=16&t=1549&p=7986&hilit=headless
Back to top
View user's profile Send private message
ponkeymeat
Newbie
Newbie


Joined: 15 Apr 2008
Posts: 2

PostPosted: Tue Apr 15, 2008 11:43 am    Post subject: Re: Headless option / Openoffice as service Reply with quote

Ok, i read the post put up explaining that it's probably just a Fedora issue, so I uninstalled OO 2.3 and downloaded the 2.4 RPM from the OO.org and installed that. Now I do not get the X Display error, but now nothing happens. It just sits as if it's processing the request, but nothing ever happens.

# ./soffice -headless -accept="socket,port=8100;urp;"

I have to hit CTRL+C to get back to the prompt. I run netstat -na to see if actually did start listening on port 8100. No Dice.


package openoffice.org-headless-2.4.0-9286 is installed
package openoffice.org-core01-2.4.0-9286 is installed
package openoffice.org-pyuno-2.4.0-9286 is installed

Any ideas?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group