LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   No protocol specified couldn't connect to display ":0.0" (https://www.linuxquestions.org/questions/linux-newbie-8/no-protocol-specified-couldn%27t-connect-to-display-0-0-a-752409/)

Azazwa 09-03-2009 09:43 AM

No protocol specified couldn't connect to display ":0.0"
 
Hi!

I'm trying to run a script as root, which should make a window pop up, and I think it uses another terminal as the log. At present I only have one terminal open.

It worked a while ago, and now it doesn't. From similar threads I see that other people also said that it fluctuated, but that's all help that I got.

Code:

[root@gnlserv01 scripts]# ./oscar_wizard
No protocol specified
couldn't connect to display ":0.0" at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Tk/MainWindow.pm line 55.
MainWindow->new() at ./oscar_wizard line 155

I've tried

Code:

[root@gnlserv01 ~]# xhost root
No protocol specified
xhost:  unable to open display ":0.0"
[root@gnlserv01 ~]# xhost +
No protocol specified
xhost:  unable to open display ":0.0"

Any ideas?

Thanks!

David the H. 09-03-2009 10:14 AM

xhost has to be run by the user who owns the X session, not root, because you're giving permission for root to access the display. Also, I don't think xhost can accept "root" as an entry. Try "xhost +localhost".

The program also has to know which display to use. If "echo $DISPLAY" in the root terminal doesn't show the correct display number, you'll have to set the environment variable: DISPLAY=":0.0" (or else set it individually for each command, usually with a "--display=0" option or something similar.

Azazwa 09-04-2009 03:03 AM

Hi!

I tried doing what you suggested, but it doesn't seem to work, or else I'm not using the write syntax.

Code:

[compchem@gnlserv01 ~]$ xhost +localhost
localhost being added to access control list

[CODE][[root@gnlserv01 ~]# echo $DISPLAY
:0.0
[root@gnlserv01 ~]# /opt/oscar/scripts/oscar_wizard
No protocol specified
couldn't connect to display ":0.0" at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Tk/MainWindow.pm line 55.
MainWindow->new() at /opt/oscar/scripts/oscar_wizard line 155
/CODE]

Thanks for your help so far!

Azazwa 09-04-2009 09:03 AM

[Solved] - Sort of.
 
Hi !

I closed the terminal, reopened it, checked that the $DISPLAY was set correctly, and then it worked.

This solves my immediate problem, but I don't know why the problem is actually solved.

Thanks anyway!

Shingoshi 03-14-2010 06:58 PM

Thank you for explaining this!!
 
Quote:

Originally Posted by David the H. (Post 3668396)
xhost has to be run by the user who owns the X session, not root, because you're giving permission for root to access the display. Also, I don't think xhost can accept "root" as an entry. Try "xhost +localhost".

The program also has to know which display to use. If "echo $DISPLAY" in the root terminal doesn't show the correct display number, you'll have to set the environment variable: DISPLAY=":0.0" (or else set it individually for each command, usually with a "--display=0" option or something similar.

After searching around for the solution to this, I found the simple fact stated here by you requiring me to run "xhost +localhost" as the normal user. Once I did that, I had no more trouble. I now have it set in my script to first "su $NORMAL_USER" before running any other commands, which are performed as root.

It was really annoying that I previously couldn't run any programs requiring root. Now I can launch my Slackware package manager (GSlapt) from the mc console.

Thank you!!
Xavian-Anderson Macpherson
Shingoshi

Shingoshi 03-15-2010 03:06 PM

I have a question which might help others also...
 
Is there a way to set either "init 4" or the user login to X to automatically perform the "xhost +localhost" at the beginning of every session? It would be nice if I don't have to do this every time I log into the X window. Where in /etc/X11 would this have to be done to make the change permanent?

Xavian-Anderson Macpherson
Shingoshi


All times are GMT -5. The time now is 06:42 PM.