Subject: Re: OpenOffice install error?
To: Michael Rauch <firstname.lastname@example.org>
From: Robert Elz <kre@munnari.OZ.AU>
Date: 03/04/2003 10:11:07
Date: Thu, 27 Feb 2003 22:16:12 +0100
From: Michael Rauch <email@example.com>
| > Is there a way to check for available X display numbers moderately easily?
| If anyone's got a positive answer to this question, I'd happily
| implement it.
I think this will tell you which display numbers are in use...
netstat -an |
sed -e '/\.60[0-3][0-9] /!d' \
-e 's/.*\.60\([0-3][0-9]\) .*/\1/' \
-e 's/^0//' |
Send that to tail -1 to find the last one, then add one to that, and you
should get a "not in use" display number (not necessarily the lowest,
that would take more work). Remember to handle the case of no displays
This may also occasionally hit a false positive, if something that isn't
a X server has a port open in the X server's normal range (but that should
also do no harm).
In 99.9% of environments, looking for only servers in the :0 .. :9 range
is going to work (few systems will have 10 X servers running) - but if you
do that, you'd want to make sure to do it the "hard way", not just tail -1
and add one (as some systems (like me) use :9 for the local xdm server, and
in that case, +1 would be :10, which is likely to conflict with a ssh
"server" - but numbers between :1 and :8 are typically free).