Intro


I am a computer programmer with a lot of experience. I am currently upgrading my skill set. Follow my journey learning Ruby-on-Rails, HTM5, iPhone and Android programming.

Saturday, December 18, 2010

X Server running but can not find display

I was trying to run an X windows program on a Linux computer remotely. The program did not actually display anything over X, but required to attach to the X Server to do some processing. Anyway I was getting the error:

Can't open display: 0.0

I was logged in remotely. If I logged in remotely forwarding the X port, the error did not happen. The server was running an X Server. So why this error? What was the correct DISPLAY to define to make this program work without having to forward the X port to my local computer?

The answer is that even though the Linux computer was running an X Server, it did not actually have a display card, so there was no actual display to assign the DISPLAY variable to. The fix was to create a virtual frame buffer, faking the X Server into thinking there is a frame buffer, thus a DISPLAY variable can be properly set.

To create the frame buffer:

/usr/bin/Xvfb :1 -screen 0 1024x768x16 &

Set the DISPLAY variable in the environment to 0.1

setenv DISPLAY 0.1

That fixed it. Now X windows thinks there is a frame buffer and can run X Window programs even though they are not displayed anywhere.

FYI: I had to install the Xvfb program in the server, it was not previously installed.

No comments:

Post a Comment