Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a script, simply to run my Graphical (GUI) Application, as below.

#cat gui.sh
#!/bin/bash 
./gui -display 127.0.0.1:0.0    

When I run it from local machine (./gui.sh) it runs perfectly fine. But when I am trying to run it from remote machine via ssh, I got following error.

[root@localhost]# ssh -f 192.168.3.77 "cd /root/Desktop/GUI/ && "./gui.sh""   
No protocol specified  
gdm: cannot connect to X server 192.168.3.77:0.0   
[root@localhost]#    

I don't know, which protocol it is asking or am I missing anything? I tried directly by starting the application, without script [ssh -f 192.168.3.77 "cd /root/Desktop/GUI/ && "./gui""], but the result is same. I have tried various combinations like ssh -Y, ssh -fY and more but the result is same!
Secondly for my application, there is a must condition that, we have to first go into the directory where the program is located.
Any Solutions?

share|improve this question

2 Answers 2

The meaning of the option -display 127.0.0.1:0.0 depends on that gui program, but it's highly likely that it means “display on the X display 127.0.0.1:0.0”. This is the first local X display, accessed over TCP. This is almost certainly wrong for two reasons. First, the local X display should be :0, not 127.0.0.1:0, because including an IP address causes the traffic to go through TCP instead of local access. Going through TCP may not work depending on whether the X server accepts TCP connections. Even if it does, you lose the optimizations that local displays have.

The display to use is normally indicated by the DISPLAY environment variable, and that variable tends to be set correctly automatically. (Usually, if DISPLAY has the wrong value, it's because you've been messing with it. The main exception is use of screen or tmux.)

Your program probably does look up the value of the DISPLAY environment variable, because that tends to happen automatically with xlib calls. So you should just call ./gui, your script doesn't do anything useful. If your program insists on the -display argument, make it use the environment variable:

./gui -display "$DISPLAY"
share|improve this answer

ssh -Y and ssh -X should be a good start but did you forward your X server as well?

$ grep X /etc/ssh/sshd_config
X11Forwarding yes

otherwise it won't work.

Another thing to check is the DISPLAY variable it should show something like this:

$ echo $DISPLAY
$ localhost:10.0

this was run after ssh -Y. The same variable is empty if I ssh without -Y or -X.

For differences between -X and -Y read the man page of ssh.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.