Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Error running dcop from cron
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
hippysurfer
n00b
n00b


Joined: 14 Nov 2003
Posts: 51

PostPosted: Sat Aug 07, 2004 4:24 pm    Post subject: Error running dcop from cron Reply with quote

Hi

I have a very simple bash script that uses dcop to log me out of kopete. The script works fine until I try to call it from cron.

When called from cron I get the error:

Quote:
ERROR: Couldn't attach to DCOP server!


Does anyone have any idea how I can correct this?

Many thanks.

Richard
Back to top
View user's profile Send private message
michaelkuijn
n00b
n00b


Joined: 28 Sep 2003
Posts: 72
Location: The Netherlands

PostPosted: Mon Aug 09, 2004 10:37 am    Post subject: Reply with quote

I think it's because the script is run as an other user when it's run by cron.
Back to top
View user's profile Send private message
hippysurfer
n00b
n00b


Joined: 14 Nov 2003
Posts: 51

PostPosted: Mon Aug 09, 2004 4:01 pm    Post subject: Reply with quote

With help from the kde-devel list I found a solution.

You need to have a valid DISPLAY environment variable. On my setup this means putting

Quote:
export DISPLAY=:0.0


In the script that is run from the crontab. This is not very general because the DISPLAY might be something other than :0.0 on some setups.

cron jobs are run under the user id of the user that setup the crontab.

Richard
Back to top
View user's profile Send private message
tomchuk
Guru
Guru


Joined: 23 Mar 2003
Posts: 317
Location: Brooklyn, NY

PostPosted: Mon Aug 09, 2004 5:40 pm    Post subject: Reply with quote

If you want it to be more general you can probably grab DISPLAY from X's process information:
Code:

#!/bin/sh
PIDOFX=`pidof X`
CMDLINE=`cat /proc/$PIDOFX/cmdline`
DIS=":`echo $CMDLINE | cut -c 3`.0"
echo $DIS
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum