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

start OO with no user interface and no X ?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
carpatic
Power User
Power User


Joined: 04 May 2005
Posts: 80

PostPosted: Wed May 04, 2005 1:30 am    Post subject: start OO with no user interface and no X ? Reply with quote

I'm using OO on Linux (RedHat9) to convert files (doc, html, pdf) through python scripts.
1) I'd like to be able to start OO without having to start X
Currently, I start OO with
soffice "-accept=socket,host=localhost,port=2002;urp;"
How can I set the DISPLAY variable so that it won't require X ?

2) If I start OO from terminal on X, with the above line, OO starts with user interface active, and at each conversion that I make through script, another window instance opens with the source file content loaded. If I use intensively the conversions, I soon end up with hundreds of OO active windows !! Can I start OO with NO user interface, more like as a background service ??

Thank you
Back to top
View user's profile Send private message Send e-mail
hol.sten
Super User
Super User


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

PostPosted: Wed May 04, 2005 1:56 am    Post subject: Re: start OO with no user interface and no X ? Reply with quote

carpatic wrote:
2) If I start OO from terminal on X, with the above line, OO starts with user interface active, and at each conversion that I make through script, another window instance opens with the source file content loaded. If I use intensively the conversions, I soon end up with hundreds of OO active windows !! Can I start OO with NO user interface, more like as a background service ??

Use the parameter "-headless". Your command will look like this
Code:
soffice "-accept=socket,host=localhost,port=2002;urp;" -headless


carpatic wrote:
I'm using OO on Linux (RedHat9) to convert files (doc, html, pdf) through python scripts.
1) I'd like to be able to start OO without having to start X
Currently, I start OO with
soffice "-accept=socket,host=localhost,port=2002;urp;"
How can I set the DISPLAY variable so that it won't require X ?

You need an X server. OOo without one is impossible. Even with the parameter "-headless": http://www.oooforum.org/forum/viewtopic.phtml?t=2986

But you can use Xvfb, an X vitual frame buffer: http://www.oooforum.org/forum/viewtopic.phtml?t=11890&highlight=headless

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


Joined: 04 May 2005
Posts: 80

PostPosted: Wed May 04, 2005 2:11 am    Post subject: Reply with quote

Well, starting with -headless does the trick (no interface is opened at start), BUT each time I do a conversion the result file is still opened in a new interface.
Confused
So I still end up with LOTS of useless interfaces. Sad
Actually, I've figured out the cause. Here is a method form the script I use:
Code:

def DocToHtml(docPath, pdfPath):
    cSourceFile = docPath
    cSourceURL = pathnameToUrl( cSourceFile )
   
    cTargetFile = pdfPath
    cTargetURL = pathnameToUrl( cTargetFile )
   
    oDoc = openURL( cSourceURL )
 
    oDoc.storeToURL( cTargetURL, (createPropertyValue("FilterName","HTML (StarWriter)"),) )

Notice the "openURL" call. This opens the interface loading the source file in it. Do you know how an alternative to openURL which can work in this context ?
Back to top
View user's profile Send private message Send e-mail
hol.sten
Super User
Super User


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

PostPosted: Wed May 04, 2005 3:15 am    Post subject: Reply with quote

carpatic wrote:
Do you know how an alternative to openURL which can work in this context ?

Sorry, but I'm not a Python expert. I do everything from Java. And after my Java application established an OOo connection, no further interfaces are opened.

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


Joined: 04 May 2005
Posts: 80

PostPosted: Wed May 04, 2005 3:18 am    Post subject: Reply with quote

Well, after searching through the forum I've come up with the solution:
oDoc.dispose() will close the document.
I've found another approach:
oDoc = openURL( cSourceURL,(createPropertyValue("Hidden",1==1),) )
This is intended to open the source file wihtout an interface.

What is the difference (if any) between -invisible and -headless params ?
Back to top
View user's profile Send private message Send e-mail
hol.sten
Super User
Super User


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

PostPosted: Wed May 04, 2005 5:05 am    Post subject: Reply with quote

carpatic wrote:
What is the difference (if any) between -invisible and -headless params ?

"-invisible" starts OOo without and UI. But you can open documents inside that OOo process and make the UI visible.
"-headless" starts OOo without any UI. Although in your environment the difference wasn't that clear Wink

More about OOo parameters in this german document: http://de.openoffice.org/doc/setupguide/1.1/installations_handbuch6.html

With kind regards
hol.sten
Back to top
View user's profile Send private message
rajriyer
Newbie
Newbie


Joined: 04 May 2005
Posts: 2

PostPosted: Thu May 05, 2005 8:44 am    Post subject: making an oo connection to run java servlets Reply with quote

Hi hol.sten,

Can you cut/paste or send that piece of java code which helps you keep the oo connection ??..I tried the following :

import java.lang.*;
import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;
public class OpenofficeServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException
{
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
try
{
rt.exec("/opt/tools/OpenOffice/soffice \"-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\" -headless &");
catch (IOException e)
{
// Handle Error
}
}
}

and when i try running this servlet, it connects for a very brief period and then goes away ( i was trying to do a ps -ef |grep soffice to see if there is an instance running..)..is there a way i can keep this connection for longer ??
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: Thu May 05, 2005 12:46 pm    Post subject: Re: making an oo connection to run java servlets Reply with quote

rajriyer wrote:
I tried the following :
...
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
try{
rt.exec("/opt/tools/OpenOffice/soffice \"-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\" -headless &");
} catch (IOException e) {// Handle Error}
...
and when i try running this servlet, it connects for a very brief period and then goes away.

What you wrote is nothing more than get OOo started in listen mode. To do this establishes no connection. I've never done that inside a servlet.

rajriyer wrote:
is there a way i can keep this connection for longer ??

You should read carefully the OOo Development Guide. Start with section "2.3.4 First Connection" http://api.openoffice.org/docs/DevelopersGuide/FirstSteps/FirstSteps.htm.

With kind regards
hol.sten
Back to top
View user's profile Send private message
rajriyer
Newbie
Newbie


Joined: 04 May 2005
Posts: 2

PostPosted: Fri May 06, 2005 6:35 am    Post subject: Reply with quote

Thank you so much for your reply. Is there any way I can run the soffice executable ( (/opt/tools/OpenOffice/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"....) on unix, close the XWindows session, and still have the instance running in the background for the different conversion class files to use it. One of the options I was thinking of was to run the command from a startup script on the unix machine, but wasn't sure if this would ensure that we don't need an XWindows session open all the time.

Thanks and hope this is not a stupid question.
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: Fri May 06, 2005 7:38 am    Post subject: Reply with quote

rajriyer wrote:
Is there any way I can run the soffice executable ( (/opt/tools/OpenOffice/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"....) on unix, close the XWindows session, and still have the instance running in the background for the different conversion class files to use it.

No. Closing the X session will terminate the OOo process. But as I already wrote, you can use xvfb as X server.

With kind regards
hol.sten
Back to top
View user's profile Send private message
AndrewZ
Moderator
Moderator


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

PostPosted: Wed Feb 27, 2008 4:14 pm    Post subject: Re: start OO with no user interface and no X ? Reply with quote

This is an old post, so the following is just for the record. People still read this stuff. Smile

carpatic wrote:
How can I set the DISPLAY variable so that it won't require X ?


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. IMO, -headless is easier than Xvfb.

Quote:
If I start OO from terminal on X, with the above line, OO starts with user interface active, and at each conversion that I make through script, another window instance opens with the source file content loaded. If I use intensively the conversions, I soon end up with hundreds of OO active windows !! Can I start OO with NO user interface, more like as a background service ?


The article Batch command line file conversion with PyODConverter gives a similar example.
_________________
<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
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
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