openSUSE Forums > Archives > SF Archives > ARCHIVES - Programming & Scripting » Cron & Kdialog: Cannot Connect To X Server

Go Back   openSUSE Forums > Archives > SF Archives > ARCHIVES - Programming & Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Programming & Scripting A place to discuss website design, programming, shell scripts, etc

 
Page 1 of 2 1 2
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 28-Mar-2008, 10:54
PC54G2
Guest
 
Posts: n/a
Default

Hi,

please, what's the solution to be notified by a kdialog msgbox, when a script which include something like "kdialog --msgbox "hello" is launched via Cron (as user, not root) ?

I tried this http://nixforums.org/about165610.html (give permission to user with .Xauthority) but the message is always

Code:
kdialog: cannot connect to X server
Thanxs
  #2 (permalink)  
Old 28-Mar-2008, 18:19
ken_yap
Guest
 
Posts: n/a
Default

In general you should not run interactive programs from cron.
  #3 (permalink)  
Old 28-Mar-2008, 18:24
PC54G2
Guest
 
Posts: n/a
Default

What could be the problem(s) launching personal scripts using cron ?

I've found a solution just writing kdialog --display :0....
  #4 (permalink)  
Old 28-Mar-2008, 18:41
ken_yap
Guest
 
Posts: n/a
Default

What happens if you are not running an X server when the job starts? What happens if you are not around to deal with the interaction?
  #5 (permalink)  
Old 28-Mar-2008, 18:50
PC54G2
Guest
 
Posts: n/a
Default

Quote:
What happens if you are not running an X server when the job starts?[/b]
I d'ont know... d'you think it could be "dangerous" ?

Quote:
What happens if you are not around to deal with the interaction?[/b]
well, I don't think it is a problem, this is not an interactive message, only a msgbox which notify that the job is finished

But... How could it be possible to make such an automatic job (every days at 17:45) without using cron ?
  #6 (permalink)  
Old 28-Mar-2008, 19:02
ken_yap
Guest
 
Posts: n/a
Default

No, it's not dangerous, but if you run something interactive from cron, what should it do if you are not around? Although seeing as it's only a notification, kdialog will just fail if there is no X server or the X server belongs to some other user, so nothing happens so that's probably what you want anyway.

You could send yourself some email when the job finishes.
  #7 (permalink)  
Old 28-Mar-2008, 19:08
ken_yap
Guest
 
Posts: n/a
Default

Another possibility is to run the "write" program like this:

echo "Job finished" | write pc54g2

Substitute with your username of course.

If you have allowed writes to the terminal with "mesg y", then you will see a popup appear.
  #8 (permalink)  
Old 28-Mar-2008, 19:20
PC54G2
Guest
 
Posts: n/a
Default

In fact, at 17:45 I can be sure that I will be around the computer, and not in int3 level. Of course a problem is possible, but the probability is low. And I'm alone to use this computer.

Yes, email and "write" are good ideas too. In fact, in kdialog's msgbox, there's the content of a text file (file.txt) which results from the execution of the scripts (each script correctly executed write something in this file.txt).
I tried :

Code:
cat file.txt | write pc54g2
and it works fine. Just something, when the popup appears, I see in the titlebar "kwrited", is it related to KDE ? so the problem should not be the same as Kdialog's one if an X-session is not launched ?
  #9 (permalink)  
Old 28-Mar-2008, 19:26
ken_yap
Guest
 
Posts: n/a
Default

Yes, kwrited also depends on there being a display. But if you happen to be logged in on a terminal line, e.g. ssh, and have mesg enabled, it will go there.

write pc54g2 < file.txt

is shorter.

And seeing as there is output, mailing yourself the output would be a good idea. Although you could simply let the output go to stdout in the job, either by default or explicitly (cat file.txt), and the output of a cron job will be mailed to the owner.
  #10 (permalink)  
Old 28-Mar-2008, 19:37
PC54G2
Guest
 
Posts: n/a
Default

ok, thank you ken_yap
 
Page 1 of 2 1 2

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2