DBUS_SESSION_BUS_ADDRESS for script called from crontab.
Hi,
I'm writing a Bash script for wallpaper clocks which works fine on the command line but needs to be run every minute from a crontab entry so the time gets changed on the wallpaper (the wallpaper gets rebuilt every minute so the current weekday, date, month, hour, and minute become part of the wallpaper).
The script changes the wallpaper like this, depending on which version of Gnome is running:
The change wallpaper commands above run fine from the command line but when the script is run from crontab it seems the DBUS_SESSION_BUS_ADDRESS environment variable must be set otherwise the wallpaper does not get changed (although all other aspects of the script work fine).
Is there a generic way to get and set the value of DBUS_SESSION_BUS_ADDRESS from within the script which will work with both Gnome v.2 and v.3 and regardless of which flavour of Unix/Linux is running?
I've found 2 methods on the web:
I must say that both methods seem very inelegant! And I only know that they work on my Linux desktop which runs Ubuntu with Gnome v.2. Is there a better generic and reliable way to get and set the value of DBUS_SESSION_BUS_ADDRESS from a script called from crontab? If so, then how?
Finally, could some kind soul explain to me why I need set the DBUS_SESSION_BUS_ADDRESS so that the wallpaper will successfully be changed when running the script from crontab, while it is unnecessary when running the same script from the command line?
crontab doesn't login as you, so it doesn't get access to X.
Some of those things seem unavoidable, like the uidgen --get. Others, like the echo $DISPLAY | sed 'enormous ugly regex', can probably be made less ugly. And the eval almost certainly isn't necessary.
Without seeing what it's actually doing, of course, what those commands output and its end result, I can't rewrite it.
Last edited by Corona688; 10-15-2012 at 01:47 PM..
crontab doesn't login as you, so it doesn't get access to X.
Ok, got it.
Quote:
Originally Posted by Corona688
Some of those things seem unavoidable, like the uidgen --get. Others, like the echo $DISPLAY | sed 'enormous ugly regex', can probably be made less ugly. And the eval almost certainly isn't necessary.
Without seeing what it's actually doing, of course, what those commands output and its end result, I can't rewrite it.
In the absence of any other ways of doing it (anyone?), which would you think was most likely to work with different flavours of Unix/Linux and Gnome v.2 or 3? Or do you think both will work regardless of Unix/Linux and Gnome version?
Extremely difficult to say. dbus is a completely generic thing that can be used in a multitude of ways. Guaranteeing later versions of Gnome would work the same way because they use dbus would be like guaranteeing later versions of Gnome work the same way because they use files...
Ceiling Light - The Forgotten Element
One of the highest details concerning using an LED ceiling panel essentially offer a fantastic dance floor which definitely makes the customers dance right away.They are a quite low cost method of something like a lighting solution, simple collection up,... (1 Reply)
I want to make a config file which contain all the paths.
i want to read the config file line by line and pass as an argument on my below function.
Replace all the path with reading config path line by line and pass in respective functions.
how can i achieve that?
Kindly guide.
... (6 Replies)
Hi,
I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed.
Below is my sample... (14 Replies)
Hi all,
Warm regards!
I am in a difficult situation here. I have been trying to create a shell script which calls another shell script inside. Here is a simplified version of the same.
Calling Script.
#!/bin/ksh
# want to run as a different process... (6 Replies)
I am using blow script :--
#!/bin/bash
FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not
if
then
# echo "process found"
exit 0;
else
echo "process not found"
exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Having issues with an expect script. I've been scripting bash, python, etc... for a couple years now, but just started to try and use Expect. Trying to create a script that takes in some arguments, and then for now, just runs a pwd command(for testing, final will be command I pass).
Here is... (0 Replies)
There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg)
configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (4 Replies)
Please help me on below..
https://www.unix.com/shell-programming-scripting/141533-retrieve-value-environment-variable-shell-script-called-crontab.html#post302442024
I'm still here. I can still see you! (0 Replies)
There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg)
configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (0 Replies)
How do i get the value of the variable from the called script(script2) to the calling script(script1) in ksh ?
I've given portion of the script here to explain the problem.
Portion of Script 1
=============
-----
-----
tmp=`a.ksh p1 p2 p3`
if then
# error processing
fi
-----... (10 Replies)