Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A /dev/null equivilent for DISPLAY when the display is just noise

Tags:

I'm running a java app which creates a visual display of some of the things it is doing, while it is doing it. However, I'm want to run this in a script that won't have a display to attach to. In the current environment, there isn't even a DISPLAY environment variable set. I tried to simply set my DISPLAY to :0.0. But that doesn't exist. I don't really care about the display. I just want the app to process the files silently.

Since I can't just turn the display off(not my app), I'm left with trying to get around the need for display.

Is there a black hole that I can send the DISPLAY to? an equivalent to /dev/null?

I searched around for a bit on the web, but the words I could think of to use: "display" "null" "disregard" etc are all two generic to get me to an answer.

This is the middle of a larger script, so I want the rest of the output to stdout to be available.

like image 326
Marc Avatar asked May 07 '09 13:05

Marc


People also ask

How does Dev Null work?

The null device is typically used for disposing of unwanted output streams of a process, or as a convenient empty file for input streams. This is usually done by redirection. The /dev/null device is a special file, not a directory, so one cannot move a whole file or directory into it with the Unix mv command.

How do you read Dev Null?

You write to /dev/null every time you use it in a command such as touch file 2> /dev/null. You read from /dev/null every time you empty an existing file using a command such as cat /dev/null > bigfile or just > bigfile. Because of the file's nature, you can't change it in any way; you can only use it.

What is tail Dev Null?

tail -f /dev/null is usually added because the process (pid 1) in your docker container is not running in the foreground and if nothing is running in the foreground, docker automatically closes itself.


1 Answers

There's a headless X server called Xvfb. It's basically what you need since it accepts X clients but basically does nothing with the data from them. From that linked page (slightly paraphrased):

Xvfb, the X virtual framebuffer, is a display server implementing the X11 display server protocol.

In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output.

From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown.

This virtual server does not require the computer it is running on to have a screen or any input device. Only a network layer is necessary.

If you can't find that, then another possibility would be to use a spare PC with a full CygWin install. CygWin comes with a full-blown X server which you could connect your application to (and just ignore it). You could even set it up as the corporate /dev/null DISPLAY.

But I'd look into Xvfb first.

like image 77
paxdiablo Avatar answered Oct 21 '22 09:10

paxdiablo