Attempting to open Perl/Tk window by anacron
Hello,
I'm attempting to use "anacron" to start a Perl/Tk script which I wrote "remind_to_backup". When I'm starting it from a terminal (as root) - it opens OK. But when I didn't see it open by "anacron" I looked in "/var/spool/mail/root" and saw the following message: Code:
From root@localhost.localdomain Mon Mar 12 14:31:02 2012 here is lack of permission for "root" to access the X windows server (If I understand correctly). What I don't quite understand is why I can open this window from an ordinary root shell but "anacron" can't open it? The shell I prefare to use is "tcsh", the appropriate line in /etc/passwd file is: root:x:0:0:root:/root:/bin/tcsh which is different from the original shell (bash) after the installation (FC14). How can I know, in what shell the "anacron" runs? What's the difference (from the standpoint of X server access) between programs called by "anacron" and same programs called from the command line (by root)? While searching the net I saw suggestions like: xhost +root or xhost +localdomain but I have none of such commands in my /root/.tcshrc file but still, I can open the Perl/Tk window as root from the command line. TIA for any ideas, kaza. |
This teaches us a few things.
Firstly: you seem to run your machine as root; bad idea ;} Secondly: you have bad taste in shells... (sorry, couldn't resist). Anyway, to solve your problem (I don't think it's shell related) just issue in the running X-session: xhost +localhost And in the cron file prepend the bit that starts your Tk script w/ DISPLAY=:0.0 Cheers, Tink |
Hi Tinkster,
thanks for the reply. I don't run as root usually, I login as other user. But to test this script I first did "su -" since I wanted to test as close as possible to the real situation when the "anacron" will call it. I added xhost +localhost > /dev/null to the /root/.tcshrc and changed the line in /etc/anacrontab from: 7 50 remind_to_backup env DISPLAY=:0 nice remind_to_backup to 7 50 remind_to_backup env DISPLAY=:0.0; nice remind_to_backup Now I'll wait few days to see what the result will be. Thanks, |
Wait a sec ... so, which user are you running your X-session as?
|
Hi Tinkster,
During boot at login prompt I log in as a normal user, when I run "ps" I see that gnome-session is run by my login user. I checked "ps | grep root" and as far as I can tell I only saw low level or hardware related processes run by root. Does it adds more insight as to the original problem cause? TIA, kaza. |
Nope. It means that you need to do the xhost +localhost from your normal
user account; as an aside, that most likely won't work from your ~/.profile/ ~/.tcshrc because xhost needs to be run from within X. Find out whether Gnome can run scripts and such during login, and add it to that. Cheers, Tink |
All times are GMT -5. The time now is 10:55 PM. |