There are a few things that might stop XDISPLAY from working as you intended. These are problems with security, multi-hop logins and inappropriate use.
If you are logged into the Compaq Alpha rlsaxps
from the SUN Sparc rlssp0
, and you type
xdisplay
, then it is possible that you will get a message such as:
To fix this, you need to make sure that the client is authorized to send X output to the server. If you do not know how to do this, consult your site manager.
A problem that is not so easily overcome, but is probably less likely to occur, is that of multi-hop logins.
If you are using X-terminal xacc
with an X session on Compaq Alpha rlsaxps
, and you log into
Compaq Alpha rlsaxp2
, and then type xdisplay
on rlsaxp2
, XDISPLAY thinks you are on
rlsaxps
and will point the display back to rlsaxps
. This will fail because rlsaxps
is a server
machine and does not have an X console.
A somewhat more embarrassing possibility is that you have logged in from one workstation (A) to a
second (B), and thence to a third machine (C). If you then type xdisplay
on C it will successfully
point the X output back to B if the security setting allows it. The trouble is that you are sat in front of A
wondering where the window has gone and the user sat in front of B is wondering why a random
window has suddenly appeared, and worse, possibly trashed what was displayed on a pre-existing
graphics window!
Making XDISPLAY automatically cope with multi-hop logins verges on the impossible, but there is a simple manual override available. If you type
where <nodename>
is the name of the computer or X-terminal that you want the display to appear on,
then the display will appear on that X-server, regardless of the route that you used to log
in.
Note that you can only use the xdisplay
command interactively. You cannot put it in
a shell script as xdisplay
is actually an alias that uses the shell’s command line recall
features.
If you need to use XDISPLAY in a file there are two possibilities. If you want to have XDISPLAY work out where you logged in from, put:
in your file. This will generally be your .login
file. If you want to explicitly set the node that output
will appear on, then simply set the environment variable DISPLAY, e.g.:
which is all that XDISPLAY does anyway.
If you give XDISPLAY the explicit node name, it is also possible to specify the transport mechanism to use. On Unix systems, you can select the transport to be used by the case of the node name. If it is purely in upper case, then DECnet will be used. Anything else will cause TCP/IP to be used, which is normally what is required.
Finally, if you try to use XDISPLAY in an inappropriate way then you probably will not get what you expected. For example, if you log into a computer from a VT type terminal connected to a TCP/IP terminal server, then XDISPLAY will quite happily point your X output to the terminal server. It is only when you come to run an X application that you will see the problem.