1

The goal: to be able to get an "infobox" to open in a terminal after some time; alarm clock style, (on a Debian derived linux box). However:

> at now + 3 min
dialog --infobox "Time to attend to matters\!" 6 33

produces no output. and a system email that says "Error opening terminal: unknown". So we prefix the dialog with some environmental variable stuff which did the trick in the past, that the command after "at" now looks like this:

TERM=linux DISPLAY=":0.0" dialog --infobox "Seek ye the truth\!" 6 33

Now the only thing produced is a system email filled with escape sequences, which i'll guess is the output of dialog itself? How can one get dialog to play well with "at"? (thankee!)

Theophrastus
  • 926
  • 7
  • 13

2 Answers2

0

at and cron are tools for running commands unattended. The planned command can be run when the user session does not exist or when user is logged in at different terminal so the atd daemon reads the standard output of the command and sends it to the user via email. When user wants to do something else then he must redirect the standard output. But redirect to user terminal is rather tricky because the command has to determine the terminal somehow.

If you want to display something after a delay then try something like

(sleep 10 && /bin/echo "game over") &
  • I ended up hitting upon an nice solution involving the 'at' command combined with a python script calling its notify module. It does exactly what I hoped for using dialog. I can now: "at now + 53 min" followed by "mynotify.py" ...perfect alert system. Thank you anyway! – Theophrastus Jul 05 '15 at 22:19
0

The commands using dialog do not work because there is no terminal (tty) associated with the at process. Like cron, at is intended to be a noninteractive environment. Since there is no terminal for dialog to interact with, setting TERM does not help.

If you happen to be logged in (and have X running), you can make dialog appear in a separate terminal. For instance:

at now -f foo

where foo has

xterm -display :0 -e dialog --msgbox "Seek ye the truth!" 6 33 &

works well enough:

dialog run from at-script

but adds a few changes:

  • an infobox will flash on the screen and go away too quickly. Use a msgbox instead
  • don't wait in the at/batch job for it to complete: use "&"

If you need a response from dialog, you should keep in mind that it normally writes the text-interface to the standard output, and its response to the standard error. You can reverse that (making scripts simpler) using the --stdout option. (zenity does not support this option, so you might want to accommodate that by a scripting workaround).

Further reading:

Thomas Dickey
  • 76,765