LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-03-2009, 09:43 AM   #1
Azazwa
Member
 
Registered: Mar 2009
Distribution: Fedora 8, Ubuntu 9.10, SuSE 10, Fedora 14
Posts: 98

Rep: Reputation: 15
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!
 
Old 09-03-2009, 10:14 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
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.

Last edited by David the H.; 09-03-2009 at 10:17 AM. Reason: Small error correction
 
Old 09-04-2009, 03:03 AM   #3
Azazwa
Member
 
Registered: Mar 2009
Distribution: Fedora 8, Ubuntu 9.10, SuSE 10, Fedora 14
Posts: 98

Original Poster
Rep: Reputation: 15
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!
 
Old 09-04-2009, 09:03 AM   #4
Azazwa
Member
 
Registered: Mar 2009
Distribution: Fedora 8, Ubuntu 9.10, SuSE 10, Fedora 14
Posts: 98

Original Poster
Rep: Reputation: 15
[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!
 
Old 03-14-2010, 06:58 PM   #5
Shingoshi
Member
 
Registered: Oct 2006
Location: Cochise County, Arizona
Distribution: Gentoo-AMD64 / Slackware64-Current
Posts: 474
Blog Entries: 28

Rep: Reputation: 34
Thank you for explaining this!!

Quote:
Originally Posted by David the H. View Post
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
 
Old 03-15-2010, 03:06 PM   #6
Shingoshi
Member
 
Registered: Oct 2006
Location: Cochise County, Arizona
Distribution: Gentoo-AMD64 / Slackware64-Current
Posts: 474
Blog Entries: 28

Rep: Reputation: 34
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem starting gui, "$DISPLAY is not set or cannot connect to the x server" GlennsPref Mandriva 14 02-28-2009 06:15 PM
Cannot connect to X11 window server using ":).0" as DISPLAY variable cclack Linux - Newbie 4 09-06-2007 09:32 PM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
anging "Protocol" option to "IMPS/2" in XF86Config-4 causes problems zstingx Linux - General 2 10-27-2003 09:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration