View previous topic :: View next topic |
Author |
Message |
hippysurfer n00b
Joined: 14 Nov 2003 Posts: 51
|
Posted: Sat Aug 07, 2004 4:24 pm Post subject: Error running dcop from cron |
|
|
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 |
|
|
michaelkuijn n00b
Joined: 28 Sep 2003 Posts: 72 Location: The Netherlands
|
Posted: Mon Aug 09, 2004 10:37 am Post subject: |
|
|
I think it's because the script is run as an other user when it's run by cron. |
|
Back to top |
|
|
hippysurfer n00b
Joined: 14 Nov 2003 Posts: 51
|
Posted: Mon Aug 09, 2004 4:01 pm Post subject: |
|
|
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 |
|
|
tomchuk Guru
Joined: 23 Mar 2003 Posts: 317 Location: Brooklyn, NY
|
Posted: Mon Aug 09, 2004 5:40 pm Post subject: |
|
|
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 |
|
|
|