We help IT Professionals succeed at work.
Get Started

How to fix X11 display issue?

Last Modified: 2013-12-06
When running this cronjob on my Fedora 7 Server:

# create pdfs and preview  
*/15 * * * * /usr/bin/convertdir2pdf restart /var/www/html/_files >> /var/www/html/_logs/convertdir2pdf.log 2>> /var/www/html/_logs/convertdir2pdf.log #JOB_ID_5

I am getting this error :

/usr/lib/openoffice.org/program/swriter.bin X11 error: Can't open display: localhost:0.0
   Set DISPLAY environment variable, use -display option
   or check permissions of your X-Server
   (See "man X" resp. "man xhost" for details)

I made sure that DISPLAY=:0.0 is in the crontab file but still giving my problems, any solution ?

My guess is that the problem is because of this line in the macro (see macro below)

"oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))"

so that the macro needs a X11 running, is there any solution to run this macro w/o GUI?
This is the content of "/usr/bin/convertdir2pdf" :
/usr/bin/oowriter -display localhost:0.0 -accept="socket,host=localhost,port=2002;urp;" -headless "macro:///Standard.Module1.ConvertWordToPDF($1)";
And this is the macro: 
REM  *****  BASIC  *****
Sub ConvertWordToPDF(cFile)
   cURL = ConvertToURL(cFile)
   ' Open the document.
   ' Just blindly assume that the document is of a type that OOo will
   '  correctly recognize and open -- without specifying an import filter.
   oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))
   cFile = Left(cFile, Len(cFile) - 4) + ".pdf"
   cURL = ConvertToURL(cFile)
   ' Save the document using a filter.
   oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName", "writer_pdf_Export"), ))
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   MakePropertyValue() = oPropertyValue
End Function

Open in new window

Watch Question
Top Expert 2005
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE