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

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...

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 ?

Related

"Cannot open display" error when trying to install JBoss on Linux

I am unable to install JBoss on a Linux VM virtual box.
I'm getting this error:
$ java -jar jboss-eap-6.2.0-installer.jar
(.:1616): Gtk-WARNING **: cannot open display:
How can I fix this?
The EAP installer has a graphical interface. It looks as if your Linux VM either doesn't have an X desktop, or you are logging into it using something other than an X session. To use the graphical installer you will need to run it from a shell within an X desktop (in which case you might just need to set do export DISPLAY=:0.0 or something similar); or you'll need to take some other convoluted steps to get X running and be able to run executables against the X server.
If you can't run an X desktop, or don't want to, I believe EAP is available as a zipfile you can just unpack.
You have to provide a value for the DISPLAY variable, e.g. in my case
Microknoppix:~$ echo $DISPLAY
:0

XQuartz error on ssh connection

I'm connected to a remote Linux server via ssh, and I'm trying to execute ImageMagick's display command. I know that the problem is probably not on the server side, because when I connect from different machines I don't get the same problem. And I installed XQuartz on my local machine as well as connected using the ssh tags -Y and -X (neither fix the problem) and I'm still getting the following error. My computer is a MacBook Pro running El Capitan. Any idea?
display: unable to open X server `' # error/display.c/DisplayImageCommand/426.
Thanks!
I think the trick is to start XQuartz in the background on your Mac before you do anything and allow remote machines to connect.
So, on your Mac, in Terminal, start XQuartz:
X &
Now right-click the XQuartz icon in your Dock and click:
Applications -> Terminal
and in the Terminal that appears, type:
xhost +
Later, when you have it working, tighten up the security on the xhost command by being a bit more specific with IP addresses.

How to share Mac screen to Linux docker container?

I want to run odesk time tracker (a Qt4 app) which captures your screen and keystrokes for freelance work logging. But I don't trust it and want to sandbox it.
On Linux, there are ways to run GUI items on docker container and forward X11 to Linux host. Can I do this on mac? The app will run on Linux container and will be displayed on Mac with capturing screen/keystroke.
I think VNC method would display the linux host, not the mac. If linux connects mac, I have to install the software on mac. I don't know if I can do X11 forwarding.
You need to have XQuartz installed on your Mac. You can get it here -
http://xquartz.macosforge.org/landing/
Once you installed it, follow this procedure -
Run X11 application (included with XQuartz)
Open X11 Preferences and make sure "Allow connections..." is checked
Restart X11 application
Open a terminal
ssh to your docker with X11 forwarding: ssh -X YOUR_DOCKER_IP
From now on, any GUI application that you run on your docker will show up on your Mac.

SSH tunnelling into arch box

I have a raspberry pi running arch linux connected to the TV and want to run commands on that screen by SSH'ing from my Ubuntu machine elsewhere.
I have tried running the command SSH -Y root# and starting xclock as a test. However I get the following error:
No protocol specified
Error: Can't open display: :0
I then tried running "export DISPLAY=:0" on the arch machine, but this doesn't solve the issue.
I have X running fine and can see it on the TV and I have edited the file /etc/ssh/ssh_config to allow X11 forwarding.
Anyone know what I am doing wrong?
Many thanks
The ArchLinux wiki has some good instructions on setting things up. I struggled for a while until I found them, but for me the key was to set up SSH forwarding within sshd_config (most distros seem to enable this by default, but Arch doesn't).
Once you've enabled X forwarding in SSHD, I also found it helpful to install the dummy video driver for Xorg ("pacman -S xf86-video-dummy"), which gets rid of irritating errors about missing the RANDR extension. This might not be necessary if you already have it running a real X server locally on the Pi - personally, I'm running mine completely headless.
I've found that I don't have to worry about setting up the DISPLAY variable, or xhost, when running with 'ssh -X' from an iMac. I'd expect Ubuntu to behave the same.
looks like an authentication problem. The answer used to be
xhost +
on the console of the X display. Might help.
You probably want to set
export DISPLAY=[IP_ADDRESS_OF_ARCH_BOX]:0
on your Ubuntu box, then when you run xclock from your Ubuntu box, it'll forward the screen to the Arch box.

Attach/Detach to a remote instance of Eclipse

When using Eclipse over X-Windows on a remote shell (X port forwarding), is there a way to simply detach my X connection and come back to the process later. For a little more clarity, I'm on a Windows machine and have to reboot. I'd like to keep Eclipse running and come back where I left off. Eclipse is running on my Windows machine through an X-Server connected to a Linux box.
I'm thinking something like tmux could do the trick. However, I do a Ctrl-Z to stop Eclipse and it won't close the Eclipse Window. If I restart the X-Server in Windows, Eclipse fails when I try fg 1. Any other options?
Xpra did everything that I needed, but it was not clear exactly how it worked. I was able to get it working by opening two PuTTY sessions in windows, one server and one client. Also, the Google Code is out-dated. Instead, install from http://xpra.devloop.org.uk/dists/xpra-0.0.7.9.tar.bz2. I'm not sure how it's different, but it worked for me. The README tells how to build the package. It is necessary to apt-get a bunch of other stuff. But, here are the missing pieces on how to get it work as I describe above:
Setup server:
cd ~/download/xpra/xpra-0.0.7.9
export PYTHONPATH=$PWD/install/lib/python:$PYTHONPATH
./install/bin/xpra start :10
export DISPLAY=:10
xterm&
Setup client:
cd ~/download/xpra/xpra-0.0.7.9
export PYTHONPATH=$PWD/install/lib/python:$PYTHONPATH
./install/bin/xpra attach :10
Notes:
The Windows xpra installer is not needed for this configuration. I don't know what it's supposed to do.
Be sure to run Xming on Windows.
Be sure to enable X port forwarding on the client PuTTY window.
Launch whatever you want from the xterm window. (ie Eclipse)
You can close the server window once xterm is up.
Hit ctrl-c in the client window to detach from the session.
Do all the client commands again to re-attach..even after restarting PuTTY, the Xming, or Windows itself.
I have zero experience with it, but xpra sounds like exactly what you're looking for.

Resources