[Solved] OOo Writer in cron

Issues with installing under all Linux Distributions

[Solved] OOo Writer in cron

Postby sirc » Thu Jan 10, 2008 10:21 pm

I am using Ubuntu Gutsy

I have a script: /usr/tbin/TransfertWeb.sh that have the following command to print a .rtf file :
/usr/bin/oowriter -invisible -pt Lexmark_E232 /usr/tbin/TransfertWeb.rtf

The script works properly.

When I call the script from cron (fcron) nothing prints

My fcrontab lise is:
10 7 * * 3 /usr/tbin/TransfertWeb.sh

Any idea ?
Last edited by Hagar Delest on Tue Jun 10, 2008 11:20 am, edited 2 times in total.
Reason: tagged the thread as Solved.
sirc
 
Posts: 5
Joined: Thu Jan 10, 2008 10:14 pm

Re: oowriter in cron

Postby acknak » Thu Jan 10, 2008 10:51 pm

[Moved to Setup / Linux forum] This is more Linux-specific than Writer-specific

The first rule of using cron: processes started by cron have no (or almost no) normal environment setup. You may need to add a "printenv" to see exactly what is there, but it won't hurt to assume there's no environment at all. You'll probably have to set HOME, PATH, LANG, at least, maybe others.

You should probably set this up a special user just for this purpose, and then your script will need to take care of changing to the proper HOME directory for that user. Even in that case, I would lose sleep at night if I had OOo running with some random RTF input file. Who knows what a craftily-hacked RTF file could make OOo do?

I expect there are already some guides around for setting up OOo to run "headless" like this. I don't know where that might be, but you may want to hunt around for one (or maybe someone else here knows of one) before you go re-inventing the wheel.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: oowriter in cron

Postby sirc » Fri Jan 18, 2008 10:26 pm

I add all the printenv variables to fcrontab without any results

I saved the rtf file in an odt format without any result

Finally I put it back in a rtf file on a Windows XP and use the scheduler with WordPad and everything works fine.

Only deception is to not be able to work with it on my Linux Server. All the others scripts that I have on Linux works fine in fcron. Only oowriter dont.
sirc
 
Posts: 5
Joined: Thu Jan 10, 2008 10:14 pm

Re: oowriter in cron

Postby Hagar Delest » Sun Jan 20, 2008 10:29 pm

Could it be another bug from the Ubuntu version of OOo? You could give the official version a try: [Ubuntu] Installing OOo on Debian and Co.
LO 6.4.6 on Xubuntu 20.04 and Windows 10.
User avatar
Hagar Delest
Moderator
 
Posts: 29078
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: oowriter in cron

Postby hol.sten » Sun Jan 20, 2008 10:54 pm

acknak wrote:You should probably set this up a special user

If you follow this advice, you have to go through the first start wizard of OOo for this special user or you have to add -nofirststartwizard to your printer command:
Code: Select all   Expand viewCollapse view
/usr/bin/oowriter -invisible -nofirststartwizard -pt Lexmark_E232 /usr/tbin/TransfertWeb.rtf
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
hol.sten
Volunteer
 
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: oowriter in cron

Postby sirc » Mon Jan 21, 2008 6:36 pm

For Hagar de l'est:
Oo version I am using is 2.3.0 which is the official version linked to Ubuntu 7.10

For hol.sten :
I did tried it on a regular user's fcrontab instead of root with the same result.

-nofirststartwizard had no succes either with or without inserting all printenv variables
sirc
 
Posts: 5
Joined: Thu Jan 10, 2008 10:14 pm

Re: oowriter in cron

Postby acknak » Mon Jan 21, 2008 9:02 pm

Ugh--as usual, I should have kept my mouth shut, as I really had no clue what I was talking about--or I should say, what I know is now obsolete.

Since I shot my big mouth off, I feel some need to track down a better answer.

First, it seems that modern cron does provide a minimal environment, so that's not the issue.

Second, even using the "-invisible" or "-headless" options, OOo still requires an X display to connect to. I got this in the output report mail from cron:
/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)

Checking some old threads on oooforum, I found this: http://www.oooforum.org/forum/viewtopic.phtml?t=11890, which gives an example of running OOo on a server by using a script called "xvfb-run" to run a command under the "Xvfb" virtual X server.

Once I installed Xvfb, and tracked down a copy of that script, and installed it, and set the crontab file to use that to start the "print_rtf" script... it still didn't work.

Now I got this error:
[Java framework] Error in function createSettingsDocument (elements.cxx).javaldx failed!
creation of executable memory area failed: Permission denied
FATAL ERROR, could not mmap a file for executable memory either in home dir or in /tmp
Cannot continue, perhaps examine your mount options for those directories, or selinux

I was trying to run the script as user "nobody", which apparently does not have enough permissions to allow OOo to set up it's configuration files.

Once I set the crontab to run the job as a normal user, it worked just fine.

I did not need to use the "-nofirststartwizard" option: OOo simply made a new config tree if none was present. Apparently "-headless" is enough to prevent the wizard from being triggered.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: oowriter in cron

Postby Hagar Delest » Mon Jan 21, 2008 9:47 pm

sirc wrote:Oo version I am using is 2.3.0 which is the official version linked to Ubuntu 7.10

Ubuntu version is not the "official" one. It's based on the Novell version it seems. The official version is to be downloaded on the OOo web site (available in .debs). The Ubuntu version is often heavily bugged (sadly).
LO 6.4.6 on Xubuntu 20.04 and Windows 10.
User avatar
Hagar Delest
Moderator
 
Posts: 29078
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: oowriter in cron

Postby sirc » Mon Jan 21, 2008 11:14 pm

There's my new script (TransfertWeb.sh)
--------
#!/bin/bash
export PATH=$PATH:/usr/bin/X11
export LANG=fr_CA.UTF-8
export HOME=/home/sirc

xvfb-run -a /usr/bin/openoffice -invisible -nologo -headless -pt Lexmark_E232 /data/Transfert/TransfertWeb.odt
------------

When I run it, I got the same error as you :
/usr/lib/openoffice/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 look in the pages that you suggest but I did not find who to setup my script

I did try with -display :0, -display :1 and -display :99 with the same result

I will appreciate if you can give me the example you did

Thanks
sirc
 
Posts: 5
Joined: Thu Jan 10, 2008 10:14 pm

Re: oowriter in cron

Postby hol.sten » Tue Jan 22, 2008 12:17 am

Try these hints:

1) Use OOo 2.3 really headless: OOo 2.3 Headless X11 requirements:
Install the following OOo headless RPM on your Linux system:
dustymugs wrote:The package I'm referring to is in the standard tarballs available at openoffice.org:
- OpenOffice 2.3.0: openoffice.org-headless-2.3.0-9221.i586.rpm
- OpenOffice 2.3.1: openoffice.org-headless-2.3.1-9238.i586.rpm

And install these:
dustymugs wrote:Libraries: libXext.so.6, libSM.so.6, libICE.so.6, libX11.so.6, libXau.so.6, libxcb-xlib.so.0, libXdmcp.so.6

Unfortunately, only having these libraries causes problems in terms of output. This is particularly noticeable in PDF outputs. To have everything output right, install:

fontconfig

You could install any of the additional X11 fonts, but that is up to you. Once you have the required libraries, you should be able to run openoffice without a xserver, xvfb or vnc.



2) Try "xhost +" or add a display option like this: -display :0.0 (maybe different numbers, but no equal sign and at least one blank between -display and :0.0)
For more on this, follow these links:
- http://www.oooforum.org/forum/viewtopic ... ht=display
- http://www.oooforum.org/forum/viewtopic ... ht=display (contains a script to call OOo)
- http://www.oooforum.org/forum/viewtopic ... ht=display (tells again you must use -display :0.0 (with blank))
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
hol.sten
Volunteer
 
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: oowriter in cron

Postby acknak » Tue Jan 22, 2008 1:22 am

I have openoffice.org-headless installed, but something is still looking for a connection. I was testing with the Fedora OOo packages, perhaps the official OO.org packages would behave differently.

If you're running on a server where you don't want X installed, then it's nice to have an option of avoiding it. If you're running a "service" on a double-duty desktop machine, then there's less point in avoiding X altogether.

/etc/cron.d/cron_test:
Code: Select all   Expand viewCollapse view
*/2 * * * * ooo /usr/local/bin/xvfb-run /tmp/printrtf
Note: that runs every two minutes, which is probably NOT what you want!

/tmp/printrtf (mode 0755):
Code: Select all   Expand viewCollapse view
#!/bin/sh
/usr/bin/ooffice -headless -pt printer /tmp/dt.rtf

Ok, testing with the OO.org packages makes one big difference: it does require the "-nofirststartwizard" option, or it will fail silently when there is no user config. I guess the Fedora setup takes care of dodging the wizard in all cases.
Code: Select all   Expand viewCollapse view
#!/bin/sh
/opt/openoffice.org.latest/program/soffice -nofirststartwizard -headless -pt printer /tmp/dt.rtf


I haven't tried running it without xvfb yet.
PS: Ok, the OO.org package will run just fine without the xvfb-run wrapper, using the parameters in that last sample. The crontab command is simply "/tmp/printrtf", still running as a normal user.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: oowriter in cron

Postby sirc » Wed Jan 23, 2008 3:50 pm

A great thanks to all of you: it's works.

For other Ubuntu users there is what I did.

1- Based on hol.sten suggestion, I install the following Ubuntu Synaptic packages:
- openoffice.org-headless
- libxext6
- libsm6
- libice6
- libx11-6
- libxau6


2 - Because the command was so simple, I finally decide to not use a script but put the command directly in fcrontab. So there it is:

10 7 * * 3 /usr/bin/ooffice -headless -pt Lexmark_E232 /usr/tbin/TransfertWeb.odt


Thanks
sirc
 
Posts: 5
Joined: Thu Jan 10, 2008 10:14 pm

Re: oowriter in cron

Postby AndrewZ » Thu Feb 28, 2008 12:32 am

acknak wrote:I expect there are already some guides around for setting up OOo to run "headless" like this. I don't know where that might be, but you may want to hunt around for one (or maybe someone else here knows of one) before you go re-inventing the wheel.


I wrote a guide Batch command line file conversion with PyODConverter. Let me know if I missed anything. :)

Second, even using the "-invisible" or "-headless" options, OOo still requires an X display to connect to.


If you have OpenOffice.org 2.3.0 or greater and have openoffice.org-headless-2.3.1-9238.i586.rpm (or equivalent) package installed, then it should not require any kind of X server. I tested it, and you can test too:
Code: Select all   Expand viewCollapse view
unset DISPLAY
openoffice.org2.3 -pt Cups-PDF sample.ppt  -norestore -nofirststartwizard


Ubuntu version is not the "official" one. It's based on the Novell version it seems.


Ubuntu, NeoOffice, OxygenOffice and others based off of ooo-build, a community project. Fedora does not exactly use ooo-build, but Fedora still ships a modified OpenOffice.org. I use Fedora, but then I replace its OpenOffice.org with the vanilla version from http://www.openoffice.org because years ago I saw too many bugs.

I will appreciate if you can give me the example you did


Did you get it working?
<signature>
* Did you solve your problem? Do others a favor: Post the solution
* Visit OpenOffice.org Ninja (blog) and OpenOffice.org Ninja Wiki for news, previews, troubleshooting, etc.
</signature>
OOo 3.0.X on Fedora 9 + XP
User avatar
AndrewZ
Volunteer
 
Posts: 633
Joined: Mon Oct 08, 2007 1:25 am
Location: Colorado, USA

Re: [Solved] OOo Writer in cron

Postby acknak » Thu Feb 28, 2008 6:01 am

It was the Fedora-packaged OOo that wouldn't work without X. The OO.org package worked fine without it. I have the -headless packages installed for both.

I'm guessing that maybe it's something in Fedora's wrapper script for starting OOo. I'm not worried enough to track it down any further or try reporting it.
AOO4/LO5 • Linux • Fedora 23
User avatar
acknak
Moderator
 
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3


Return to Linux

Who is online

Users browsing this forum: No registered users and 3 guests