Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dumb Newbie Question: no $DISPLAY environment variable

2,104 views
Skip to first unread message

Tom Cat

unread,
Mar 1, 2004, 11:34:08 AM3/1/04
to
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

Bruce Hartweg

unread,
Mar 1, 2004, 12:06:03 PM3/1/04
to

Tom Cat wrote:

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

Bruce

Iain Findleton

unread,
Mar 1, 2004, 12:08:16 PM3/1/04
to
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.


Darren New

unread,
Mar 1, 2004, 12:22:34 PM3/1/04
to
Iain Findleton wrote:
> 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....

Andreas Leitgeb

unread,
Mar 2, 2004, 4:26:37 AM3/2/04
to
Darren New <dn...@san.rr.com> wrote:
> 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.

Tom Cat

unread,
Mar 2, 2004, 8:49:28 AM3/2/04
to
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

Darren New <dn...@san.rr.com> wrote in message news:<ujK0c.10064$4o3....@twister.socal.rr.com>...

0 new messages