Dumb Newbie Question: no $DISPLAY environment variable 
Author Message
 Dumb Newbie Question: no $DISPLAY environment variable

I'm on RedHat 9 and I got the bright idea to use wish to remind to do
some stuff.  Just sending my standard email reminder isn't enough
since I seem to ignore my new mail icon.  I thought I could pop up a
nice box in gnome with a short message.

I was going to use crontab call the following script:

#!/usr/bin/wish

frame .mv
pack .mv

canvas .mv.c
pack .mv.c

button .mv.c.b -text "Run Friday backup" -command exit

.mv.c create window 400 300 -window .mv.c.b

But when it runs I get the following error:

Application initialization failed: no display name and no $DISPLAY
environment
variable
Error in startup script: invalid command name "frame"
    while executing
"frame .mv"
    (file "/home/strycat/backupreminder line 3)

Any help would be appreciated.

Thanks,

-Tom



Sat, 19 Aug 2006 00:34:08 GMT  
 Dumb Newbie Question: no $DISPLAY environment variable

Quote:

> I'm on RedHat 9 and I got the bright idea to use wish to remind to do
> some stuff.  Just sending my standard email reminder isn't enough
> since I seem to ignore my new mail icon.  I thought I could pop up a
> nice box in gnome with a short message.

> I was going to use crontab call the following script:

> #!/usr/bin/wish

> frame .mv
> pack .mv

> canvas .mv.c
> pack .mv.c

> button .mv.c.b -text "Run Friday backup" -command exit

> .mv.c create window 400 300 -window .mv.c.b

> But when it runs I get the following error:

> Application initialization failed: no display name and no $DISPLAY
> environment
> variable
> Error in startup script: invalid command name "frame"
>     while executing
> "frame .mv"
>     (file "/home/strycat/backupreminder line 3)

> Any help would be appreciated.

> Thanks,

> -Tom

http://wiki.tcl.tk/CronAndTcl  should solve your problem.

Bruce



Sat, 19 Aug 2006 01:06:03 GMT  
 Dumb Newbie Question: no $DISPLAY environment variable
Quote:

> I'm on RedHat 9 and I got the bright idea to use wish to remind to do
> some stuff.  Just sending my standard email reminder isn't enough
> since I seem to ignore my new mail icon.  I thought I could pop up a
> nice box in gnome with a short message.

> I was going to use crontab call the following script:

> #!/usr/bin/wish

> frame .mv
> pack .mv

> canvas .mv.c
> pack .mv.c

> button .mv.c.b -text "Run Friday backup" -command exit

> .mv.c create window 400 300 -window .mv.c.b

> But when it runs I get the following error:

> Application initialization failed: no display name and no $DISPLAY
> environment
> variable
> Error in startup script: invalid command name "frame"
>     while executing
> "frame .mv"
>     (file "/home/strycat/backupreminder line 3)

> Any help would be appreciated.

> Thanks,

> -Tom

Yes, well, when the job runs under cron, it does not inherit the
environment of a user  logged in under X.

Your cron table entry could use the -display option to specify a
display. You have to make certain that whatever user cron is using has
the right to use the display.

i.e.

10 * * * * $HOME/myscript.tcl -display myworkstation:0:0 ...

in your cron table.

You may also need to do :

xhost +

after you log in under X (gnome, kde, whatever...) depending on your
security setup. You might also want to use a wrapper script that finds
out if you  are logged in, so that other users don't get popup notices
that you should call your girlfriend/wife/mother etc.



Sat, 19 Aug 2006 01:08:16 GMT  
 Dumb Newbie Question: no $DISPLAY environment variable

Quote:

> You may also need to do :
> xhost +
> after you log in under X (gnome, kde, whatever...) depending on your

Well, you should put something after the "+" sign. Read the man page for
xhost.

Amazing how folks will tell you to brace expr args because someone might
pass in [exec format c:\\] or some such, and then mention "by the way,
open your box up to every keyboard sniffer on the planet." ;-)

--
Darren New, San Diego CA USA (PST)
   I am in geocentric orbit, supported by
   a quantum photon exchange drive....



Sat, 19 Aug 2006 01:22:34 GMT  
 Dumb Newbie Question: no $DISPLAY environment variable
Quote:

> Amazing how folks will tell you to brace expr args because someone might
> pass in [exec format c:\\] or some such, and then mention "by the way,
> open your box up to every keyboard sniffer on the planet." ;-)

Easily explained:  The "brace expr args" folks are likely entirely
  disjoint from the "open your machine to the world" folks.

For the original poster: I'd assume that you're talking about your
  home-computer where you are your only user, and your display is
  always ":0.0".
To get it working, you need two variables:
  set env(DISPLAY) :0.0
  set env(XAUTHORITY) $env(HOME)/.Xauthority
after(!) that you add:
  package require Tk
and make the script a tclsh-script (not wish!).
 if you leave it as a wish-script, the env-setting are too late to
 have any effect.
Thus, the script should start as follows:

--- snip start of script ---
#!/usr/bin/env tclsh
set env(DISPLAY) :0.0
set env(XAUTHORITY) $env(HOME)/.Xauthority
package require Tk
--- snip end of script-header. add your code below ---

The /usr/bin/env trick usually saves me from guessing your
tclsh-location.  (There also exist other tricks to achieve
this effect)

Also remember to put it in your personal crontab rather than
the global /etc/crontab or otherwise it will not know your
Homedirectory.  If your  tclsh is not located in /usr/bin
(nor in /bin) you might need to specify its absolute path,
rather than rely on the /usr/bin/env-trick.



Sat, 19 Aug 2006 17:26:37 GMT  
 Dumb Newbie Question: no $DISPLAY environment variable
Thanks to everyone who responded.  

I luckly didn't have to mess with xhost, but I did have to have the
script set the some things.

Thanks again,

-Tom

Quote:


> > You may also need to do :
> > xhost +
> > after you log in under X (gnome, kde, whatever...) depending on your

> Well, you should put something after the "+" sign. Read the man page for
> xhost.

> Amazing how folks will tell you to brace expr args because someone might
> pass in [exec format c:\\] or some such, and then mention "by the way,
> open your box up to every keyboard sniffer on the planet." ;-)



Sat, 19 Aug 2006 21:49:28 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Dumb newbie asks dumber question

2. no display name and no $DISPLAY environment variable

3. no display name and no $DISPLAY environment variable -- ????

4. ENVIRONMENT? Dumb question 2

5. dumb questions re Win 9X vs. Linux environment

6. more dumb newbie questions

7. very newbie dumb question

8. more dumb newbie questions

9. Really dumb newbie type question

10. dumb newbie questions

11. A pretty dumb newbie question

12. dumb newbie list question

 

 
Powered by phpBB® Forum Software