Ask Your Question

Conversion to PDF from Linux cron or from non X-window session [closed]

asked 2013-10-08 15:18:19 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi all.

I have a problem with the conversion of ods documents to pdf through a shell script.

I use LibreOffice 3.4.5 on a linux workstation (CentOS 6.4).

I found the following solution:

libreoffice --headless --invisible --convert-to pdf file.ods 1>/dev/null 2>&1

which works flawlessly WHEN I USE A GRAPHICAL ENVIRONMENT.

If I try to use the script in (for example) crontab or if I connect to the workstation through ssh (without -X option) the result of the script is as follows:

/usr/lib64/libreoffice/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)

Is there any other procedure in order to convert to pdf even if the DISPLAY environment variable cannot be set?

Thank you in advance

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-10 21:29:36.332212

1 Answer

Sort by » oldest newest most voted

answered 2013-10-08 17:59:42 +0100

L-user gravatar image

I haven't tried this, don't have a Linux box at home to test this, but you problem looks like a X-Server security problem.

Execute this command in "your" user terminal (settings permissions):

    xhost +local:user_that_you_can_run_libre_office_without_a_problem

Then go to "user_that_you_can_run_libre_office_without_a_problem" user terminal, and type:

    export DISPLAY=:0

and then LibreOffice to PDF converting command.

Please report back any success or problem... P.S. Running a script using cron it executes its own shell, so probably not working because of this.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-10-08 15:18:19 +0100

Seen: 551 times

Last updated: Oct 08 '13