| View previous topic :: View next topic |
| Author |
Message |
SunnyOO Guest
|
Posted: Thu Oct 30, 2003 7:15 am Post subject: Problem running script without setting DISPLAY |
|
|
I've written a script which converts some documents to pdf, if I run
it within an open OO it works fine. My aim is to run it as a batch at night on a linux server
where OO is installed.
The batch looks like this
/usr/oo/program/soffice pdfconvert.sxw
When running the script I get:
Set DISPLAY environment variable, use -display option
but there is no DISPLAY available, I've also tried all options like -invisible etc. but
get the result.
How can I run the batch without DISPLAY ?
Thanks for your help
Chris |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
SunnyOO Guest
|
Posted: Thu Oct 30, 2003 11:13 pm Post subject: |
|
|
Thanks for the reply,
so if I got it right from the postings there is no way to start it in the background
without any X-Server ?
 |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Oct 31, 2003 9:30 am Post subject: |
|
|
| SunnyOO wrote: | Thanks for the reply,
so if I got it right from the postings there is no way to start it in the background
without any X-Server ?
 |
I don't know. I've never tried. At home I only have Linux. (SuSE 8.1) I have never tried to run OOo headless.
I don't see any reason why you couldn't run it headless with a "headless" X server. You may be able to get it to run without an X server. I've just never been motivated to try.
It may be possible. Did you see the list of command line options?
If you do run it w/o an X server. PLEASE post here how to do it. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Nov 11, 2003 8:09 pm Post subject: |
|
|
I have just conducted some experiments in running soffice headless on Linux. I'm on SuSE 8.1. I have the vnc package installed from the SuSE CD's.
I can run it in VNC. It should be possible to do this on a machine without using a monitor.
First, prepare the VNC server.
Type in a password. Then type it in again. This creates a file ~/.vnc/passwd. Whenever anyone on the Internet wants to connect using a vnc viewer to your vnc server, they need this password.
Now create a file ~/.vnc/xstartup with the commands that need to run with the X server starts. Note that VNC is a virtual X server all running in memory, it does not use any actual display hardware. But you still need a window manager. Here is my xstartup file in my .vnc directory...
| Code: | #!/bin/sh
xrdb $HOME/.Xresources
export DISPLAY=$DISPLAY
icewm
|
Now we're ready to start the VNC server.
This starts it as display :1 on my machine. (The real hardware X server is display :0.) Note that nothing visible happens at all. X display :1 is an invisible offscreen X server that can show its "screen" to a remote vncviewer.
Now set the DISPLAY variable....
Now start OOo. Make sure that no other copy of OOo is running on this machine.
| Code: | | /opt/OpenOffice.org1.1.0/program/soffice -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" |
The command shell hangs on this command. (Busy running OOo.)
Now, switch back to my reguilar GUI environment running KDE. Run my Maze Generator program written in Java. Make it draw a maze in OOo. By default the program connects to localhost port 8100, as can be seen on its second tab. It connects successfully, says "Drawing page 1", wait, wait, wait, wait, "Drawing page 2", wait, wait, wait, wait, "Drawing page 3", wait, wait, wait, wait, "Maze completed". (Get my maze generator program at OOoMacros.org.)
My java program makes an OOo draw a maze and leave the untitled drawing open. The java program does not close the document, nor attempt to make OOo quit.
So I want to use a VNC viewer to connect to my offscreen display, and see what is going on in this imaginary X server.
So I use vncviewer like this from a new command shell....
Type in the password I defined above using "vncpasswd".
A new vncviewer window appears. Inside this window, is a desktop, running IceWM and OOo, with a drawing of a maze displayed!
I close the vnc viewer window, and the shell running vncviewer returns a new command prompt.
Run the java maze generator again, just to be paranoid that it works again, indicates successful connection, drawing, etc.
Now I want to kill OOo.
| Code: | | killall -s KILL -- soffice.bin |
But upon further experimentation,I don't even need to do that. Merely killing the X server (vncserver) does this.
the vnc server shuts down, and OOo along with it.
One problem I observed, is that OOo can't run on my "real" X display and within the virtual X of the vncserver at the same time. Maybe because in both, I am the same userid?
Further investigation is warranted when I feel like it....
* I should try shutting down my REAL x-server and run in pure command line mode. (Init 3)
* Start up virtual VNC server.
* Start up OOo.
* From my other linux box (doesn't everyone have several at home?, or maybe I tend slightly towards geekiness?) run my Java maze generator. (Or I could do this from a Windows box if I had one?)
* From my other linux box, use vncviewer to "see" the virtual X display on the headless machine.
I suppose I need to build a different java program. One that connects, creates a document, saves it, and then disconnects. Maybe a "convertion" type utility of the infinite repeated variety we've gone over here, such as Word -> PDF, Excel -> Calc, etc.
Still unanswered is another user's question in Macros and API about how to make OOo terminate through the API. Someone in java wants to know this, and someone else in Delphi wants to know this. I'd like to know the answer myself.
Anyway, just some experiments and musings on headless OOo servers on Linux. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Mon Nov 17, 2003 6:51 pm Post subject: |
|
|
It is definitely possible to use Xvfp instead of vncserver.
On SuSE Linux 8.1, I did this.....
| Code: | Xvfb :1 -screen scrn 800x600x32 &
/opt/OpenOfice.org1.1.0/program soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.NamingService" -display :1 & |
This starts up an X virtual frame buffer (Xvfb) on display :1, so as not to conflict with my real, actual X display on :0.
Then it starts up a copy of OpenOffice using display :1.
I can run my Maze Generator program (written in java) and connect and draw a maze. The program goes through all the motions with all the normal messages indicating successful connection and drawing of a maze. No way to see it though. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
SunnyOO Guest
|
Posted: Tue Nov 18, 2003 3:52 am Post subject: |
|
|
Thank you very much for the detailed 'how to'
that helps me a lot.
Chris |
|
| Back to top |
|
 |
Jeremy Guest
|
Posted: Wed Dec 10, 2003 3:32 am Post subject: please, help me too ! |
|
|
hey Chris !
How did you do this script for converting those docs to PDF ?? I need it !!
please help me !
thanks !
Jeremy.
| SunnyOO wrote: | Thank you very much for the detailed 'how to'
that helps me a lot.
Chris |
|
|
| Back to top |
|
 |
Guest
|
Posted: Fri Feb 20, 2004 2:27 pm Post subject: Xvfb/vnc don't work for me, any other ideas? |
|
|
I have the exact same need as the original poster. However, I can't rely on starting vnc server or xvfb in my cron job. This is mainly because the machine it will be running on is being used by other people to run vnc, and it just isn't feasible to to try and figure out what display isn't already being used so that i could start vnc or xvfb. Is there no plan to remove the dependency on X11 for openoffice in headless mode? I so dearly need this to make openoffice a viable tool for our group. Is there a different forum where it would make more sense to make this request or pose the question?
Thanks,
Andrew |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
Guest
|
Posted: Thu Apr 22, 2004 7:42 am Post subject: |
|
|
Hello,
I start OOo on Linux as a service but I don't want to shut down OOo by using the kill command. I would prefer to close OOo via the API. Just a few lines of Java code that connect to OOo and shut down the OOo process that was started by the boot script would be perfect.
Does anybody know how the close an already running OOo process via the API?
Kind regards. |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
Guest
|
Posted: Thu Apr 22, 2004 11:45 pm Post subject: |
|
|
Hi Danny,
thanks for your answer. The terminate() method works! Here is the code.
| Code: | Object desktop = this.xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",this.xRemoteContext);
XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, desktop);
xDesktop.terminate(); |
|
|
| Back to top |
|
 |
rhofmeyr General User

Joined: 01 Dec 2006 Posts: 9
|
Posted: Fri Dec 01, 2006 5:17 am Post subject: how? |
|
|
Hi, sorry for bringing up an old thread, but I've been reading through these forums trying to get this to work.
I'm encouraged to see that it is working for some of you, and was hoping you could give some advice.
I've installed Xvfb and have followed DannyB's instructions to create a new screen and use that screen to open OpenOffice, however no matter what user I'm logged in as or what screen number I use, I get "Fatal Error: Couldn't add screen 0"
I also tried elehenaff's post here: http://www.oooforum.org/forum/viewtopic.phtml?t=11890 , which almost works. I'm getting soffice and soffice.bin in my process list...but a few seconds later I get "X11 error: Can't open display: :99
Can anyone point me in the right direction here?
Thank you very much,
Rob Hofmeyr |
|
| Back to top |
|
 |
bikram General User

Joined: 23 Aug 2006 Posts: 7
|
Posted: Sun Jan 07, 2007 10:36 pm Post subject: HI..rhofmeyr .. I did this.... |
|
|
HI...
Can U please post what Steps and Scripts u r following and using....
I did the following and everything is Still in Place and working well
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 |
|
 |
|
|
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
|