LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


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

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


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, 01:16 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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 being closed because it is a duplicate.
 
  


Closed Thread


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
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
Mplayer: [Xlib: connection to ":0.0" refused by server] elluva Slackware 2 12-18-2003 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:12 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