(Linux) How to run a program of gtk without display environment? Gtk-WARNING **: cannot open display:

走远了吗. 提交于 2019-12-20 06:38:33

问题


I got a program which must run in GTK gui environment. I can only use ssh. This program will run on a server(centos 6) and installed gnome X display.

It's no need to see GUI, but after it run finished, i can get the answer.

VNC and Remote screen is disable.

When i start the program in ssh:

Gtk-WARNING **: cannot open display:

Is there any ways to salve this problem??? I known it's bad to run a gui program in this situation, but here we only discuss technology...

Thank you...


回答1:


The ssh utility has an option -X which enables X11 forwarding.

Have you tried to connect to your destination like that ?

Or the other option is to perform the export DISPLAY=:0.0 after you log-in to your host, then run your app.

This way you'll save some network traffic, will run your app remotely, but the GUI will be displayed on the screen of the remote host.

P.S. Generally speaking your application logic might be invalid if it fails to run GUI. Are you sure that your application will do the expected stuff when it fails to run the GUI ?



来源:https://stackoverflow.com/questions/25992088/linux-how-to-run-a-program-of-gtk-without-display-environment-gtk-warning

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!