LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Closed Thread
  Search this Thread
Old 03-13-2008, 04:16 AM   #1
rajnivanza
LQ Newbie
 
Registered: Mar 2008
Posts: 3

Rep: Reputation: 0
Xlib: connection to ":0.0" refused by server


hi everybody,

i have problem regarding KDE environment.
i want to open gedit/kwrite application through program from one linux machine to another linux machine.
its work well when login user as "root" but when login user as "normal user" then display error.

I have written given below code:

cCommand = "gedit" / "kwrite"
uname = "/root" / "/home/rajni"

int executeCommand( char *cCommand )
{
char *uname = malloc (sizeof(char) * UNAME_MAX);
if(homeDir(uname) == FAILURE) {
free( uname );
setError( FNAME, "[Error] : homeDir() failed\n" );
return FAILURE;
}

pid_t pid=fork(); //don't know how vfork and environ works together.
if(pid==-1)
{
setError(FNAME,"fork failed. executeCommand()\n");
return FAILURE;
}
else if(pid == 0) //child
{
setenv("HOME",uname,1); //proper solutions pending. see ~/.Xauthority, xauth etc.
setenv("DISPLAY",":0.0",1);
free( uname );
exit(system(cCommand)); //beware of: return(system(cCommand));
}
else //parent
{
sleep(1); //let the child run first
int status;
if (waitpid (pid, &status, WNOHANG) == pid)
if (WIFEXITED (status) && WEXITSTATUS (status) == 32512) //system() returns this on
//system(unexistsing_bin);
{
char msg[100];
sprintf(msg,"unable to execute %s. executeComamnd()\n",cCommand);
setError (FNAME,msg); //not working. debug it.
return FAILURE;
}
}
return SUCCESS;
}

we get right username path and display error as :
->Xlib: connection to ":0.0" refused by server
->Xlib: No protocol specified

and so,it can't execute the "gedit" / "kwrite" Xcommand successful.

Why is this happening, and how do I fix it?

I would be very grateful if I could receive your favorable reply.

Thanks!!
 
Old 03-13-2008, 05:16 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is closed because it is a duplicate of http://www.linuxquestions.org/questi...server-626091/.

Please read the LQ rules before continuing.

Last edited by unSpawn; 03-13-2008 at 05:18 PM.
 
  


Closed Thread

Tags
xlib



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
Xlib: connection to ":0.0" refused by server Xlib: No protocol specified eyalkz Linux - Newbie 12 11-27-2018 01:30 PM
anybody familiar with this error "Xlib: connection to ":0.0" refused by server" ? rajnivanza Linux - Newbie 3 03-22-2009 05:10 PM
Xlib: connection to ":0.0" refused by server Xlib: No protocol specified eyalkz Programming 1 03-02-2004 08:22 AM
Wine not working. Xlib: connection to ":0.0" refused by server Xerop Linux - General 1 02-18-2004 09:37 PM
What is "Xlib: connection to ":0.0" refused by server " rack201 Linux - Software 1 02-04-2004 07:49 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 02:44 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
Open Source Consulting | Domain Registration