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!)

3
  • 1
    You might get something going by putting it into a bash script which redirects its stdout to the terminal in question, but that won't give you an easy way to accept user input. TBH I don't think this is going to be easy at all. What's your desired end state with this?
    – Bratchley
    Jun 18, 2015 at 18:13
  • See How to display a (zenity/GUI) dialog to the user... which answers a similar question (at and cron are very similar in this respect) Jul 5, 2015 at 17:07
  • That link is very helpful - thank you. Proves it's not only possible, but actually rather practical. I ended up using a python script instead of zenity, but either works well. Jul 5, 2015 at 22:21

2 Answers 2

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") &
1
  • 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! Jul 5, 2015 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:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .