[Solved] OOo Writer in cron
[Solved] OOo Writer in cron
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 ?
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.
Reason: tagged the thread as Solved.
Re: oowriter in cron
[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.
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
Re: oowriter in cron
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.
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.
- Hagar Delest
- Moderator
- Posts: 32670
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: oowriter in cron
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.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: oowriter in cron
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:acknak wrote:You should probably set this up a special user
Code: Select all
/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
Re: oowriter in cron
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
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
Re: oowriter in cron
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:
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:
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.
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:
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./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)
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:
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.[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
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
- Hagar Delest
- Moderator
- Posts: 32670
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: oowriter in cron
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).sirc wrote:Oo version I am using is 2.3.0 which is the official version linked to Ubuntu 7.10
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: oowriter in cron
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 :
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
--------
#!/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 :
I look in the pages that you suggest but I did not find who to setup my script/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 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
Re: oowriter in cron
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:
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))
1) Use OOo 2.3 really headless: OOo 2.3 Headless X11 requirements:
Install the following OOo headless RPM on your Linux system:
And install these: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
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
Re: oowriter in cron
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:Note: that runs every two minutes, which is probably NOT what you want!
/tmp/printrtf (mode 0755):
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.
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.
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
*/2 * * * * ooo /usr/local/bin/xvfb-run /tmp/printrtf
/tmp/printrtf (mode 0755):
Code: Select all
#!/bin/sh
/usr/bin/ooffice -headless -pt printer /tmp/dt.rtf
Code: Select all
#!/bin/sh
/opt/openoffice.org.latest/program/soffice -nofirststartwizard -headless -pt printer /tmp/dt.rtf
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
Re: oowriter in cron
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:
For other Ubuntu users there is what I did.
1- Based on hol.sten suggestion, I install the following Ubuntu Synaptic packages:
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:- openoffice.org-headless
- libxext6
- libsm6
- libice6
- libx11-6
- libxau6
Thanks10 7 * * 3 /usr/bin/ooffice -headless -pt Lexmark_E232 /usr/tbin/TransfertWeb.odt
Re: oowriter in cron
I wrote a guide Batch command line file conversion with PyODConverter. Let me know if I missed anything.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.
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:Second, even using the "-invisible" or "-headless" options, OOo still requires an X display to connect to.
Code: Select all
unset DISPLAY
openoffice.org2.3 -pt Cups-PDF sample.ppt -norestore -nofirststartwizard
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.Ubuntu version is not the "official" one. It's based on the Novell version it seems.
Did you get it working?I will appreciate if you can give me the example you did
* 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.
OOo 3.0.X on Fedora 9 + XP
* Visit OpenOffice.org Ninja (blog) and OpenOffice.org Ninja Wiki for news, previews, troubleshooting, etc.
OOo 3.0.X on Fedora 9 + XP
Re: [Solved] OOo Writer in cron
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.
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