I have been trying to use the "dialog" utility to build interactive menus. All works fine if I work from a terminal; menus are displayed and I can interact from those menus using my keyboard.

But now I want another device to be the destination for the output and another device (keypad/pointer) to provide input for the dialog.

From my existing TTY (/dev/console) I run dialog and I redirect output to /dev/tty0. The menu appears on tty0 fine; but I expected now to be driving the input from the terminal where I started the dialog script. This does not appear to work.

So can I make sure my existing TTY provides the input to dialog and then how can I inject events into dialog from a device that is not a TTY device. Can I just echo charater sequences somehow into dialog or is the issue it wants a real device that behaves like a TTY inclusing all TTY ioctls?

Simple redirection for the input does not appear to work?

  • Is this something I will have to do using a pseudo terminal? Or can I achieve this with just scripting? Commented Jul 27, 2017 at 10:22
  • I just tried some pty code to wrap my dialog script.... Commented Jul 27, 2017 at 14:39

1 Answer 1


My dialog command takes a --input-fd option to say where to read from. For example, in one terminal type tty to find it is using, say, /dev/pts/4, then set it so nothing is doing any reads:

stty -icanon && sleep 1000

In another terminal launch

dialog --yesno 'shall we answer yes?' 0 0 --input-fd 3 3</dev/pts/4

then anything typed in the first terminal affects the dialog.
Interrupt the sleep and type stty icanon to restore the first terminal.

  • Driving from one pty I seem to be able to tab between fields on the other pty; but as soon as I try and send key up / key down / space this does not work. Commented Jul 28, 2017 at 13:42
  • I thought you were connecting a device directly as input, not passing by another terminal? It was only an example demo. You might try stty raw to get the characters through unchanged in this example, but then you will not be able to interrupt the sleep. You can restore with an stty sane -F /dev/pts/4 given in a different terminal.
    – meuh
    Commented Jul 28, 2017 at 14:04

You must log in to answer this question.

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