免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1426 | 回复: 0
打印 上一主题 下一主题

How to export your X Display [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-28 01:20 |只看该作者 |倒序浏览

以下这个错误和display没有关系,注意!
# startx
X server: Error in /etc/X11/X0screens (line 614)
          Device name invalid or missing after keyword "Screen".
X server: Will try default "/dev/crt"
Failure to open default device file `/dev/crt`.
Please either specify the proper device filename in
your /etc/X11/X0screens file or fix `/dev/crt`.  This filename is either
non-existent or is not a character special file.
Fatal server error:
giving up.
xinit:  Connection refused (errno 239):  unable to connect to X server
xinit:  No such process (errno 3):  Server error.

参考....
How to export your X Display
It is possible to use your computer at home or in the labs to login to the CS machines and use cool graphical tools like xclock. The system that makes this possible is the X Windows System (X), it is the basis for all GUI application on the CS machines. One of the design ideas behind X is the idea of remote displays, in much the same way a standard telnet login works. From another computer you connect to your sever over a network login and do all kinds of neat command line things remotely. X is the method that allows you to login to the server and use neat graphical things remotely.
This document describes the basics to using this remote display function of X. It assumes that you have access to a fast network (10Base-T, or maybe ISDN speeds) and you have access to a machine that runs X applications, our CS machines do this. The software needed on your own computer is called an X server, it allows the connections from the X clients to display application on your screen. There are several X server software packages available freely for several operating systems. For Linux or other Intel architecture UNIXes
Xfree86
is common, for Windows there is
Micro-X
, and for Macs there is
MI/X
. You should follow the documentation that came with your X server for installation.
Next lets get some basics of how this all really works. On your computer your are running an X server that among other things watches a port for incoming connections. Also the X server sets up a view window where all the X application. windows will be displayed, this is called a root window. It is possible to have more than one root window. The X application you want to run on a remote computer has been compiled with libraries that allow it to communicate with the X server and tell it what to display in the root window. These applications are called X clients. When an X client is run it looks for an X server port to connect to and start issuing commands to display information. When an X server gets a connection on its port there is a small amount of security that the client has to be checked on. Usually this check is to see if the clients host is on a list of allowed client hosts. Once the check and connection is established the X server reads commands from the X client and starts building a window in the root window for the client. The servers job is not only to display graphics it also sends mouse clicks and key presses to the connected clients, in this way you have all the functionality you need to make a working GUI.
In the following paragraphs I will give several examples of how to use X using UNIX based X servers such as Xfree86. For other OSes refer to the user manual of your X server to find how to do similar things. First lets load an X server under Linux and see some of the details inside (further details of how to get this far are at
Xfree86
):
$ startx
This starts the server and by default starts a single xterm. An xterm is just a simple X client to display text in, usually a login shell. Assuming you are running bash you can look at your environment variables (EV) by typing "set". Environment variables store useful information for programs defaults or system state. If you look at your EV you will see a variable called "DISPLAY" this variable stores the address for X clients to connect to. These addresses are in the form:
hostname:displaynumber.screennumber
A typical example would be:
snake.cs.uidaho.edu:0.0
I said earlier that it is possible to have more than one X server running at a time. In this case the displayname would be something like
snake.cs.uidaho.edu:1.0
or
snake.cs.uidaho.edu:0.1
depending on how its done.
When the X clients start the look at the DISPLAY EV to see where to connect to by default. One way to do remote displaying would be to set this EV to a remote X server.
$ export DISPLAY=mymachine.mynet.uidaho.edu:0.0
Then you can run your cool X application and its display will be on mymachine.mynet.uidaho.edu.
$ xclock
Another way to do remote display is by a command line option that all X applications have: "-display [displayname]". To run your cool X application:
$ xclock -display mymachine.mynet.uidaho.edu:0.0
This does the exact same as before.
The previous demonstrations rely on whether your X server is allowing connections from remote hosts. The following command allows connections from all hosts (run on machine that the X server is running on (mymachine.mynet.uidaho.edu)):
$ xhost +
To allow connections from single hosts at a time:
$ xhost +myremote.myothernet.uidaho.edu
ssh
is a neat remote login tool that in addition to having secure encrypted transmissions auto forwards your X DISPLAY EV if your are running it under an X Server. ssh allows a easy, no hassle, way to do all of the stuff we have discussed so far. The ssh documentation has more detailed information on how to get this working.
Tips for other non-UNIX users
Because most other operating system don't have X Server as one of their basic packages using X can be quite a bit different than under UNIX. Usually all the non-UNIX X Servers do is create a root window and start watching ports. They usually don't start a Xterm to allow you to do everything you need by that. Often there are dialog boxes or menus that set the access lists and show the DISPLAY name so that you can use a external telnet program to connect to your client machine and set the variables by hand there. Your X Server software should give an example of how you might export your display using their tools.
Some Links on the topic:



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38775/showart_1018741.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP