1
3
The origin of this question, for me, is being able to run a whiptail command in a %pre
script from a kickstart file when installing a custom distribution based on Centos. However, the behaviour observed in Anaconda can easily be reproduced via the virtual terminals of any Linux system.
To run the whiptail command in Anaconda as a kickstart %pre
script it is necessary to switch TTY and execute the command in this new TTY. The prevailing suggestion as to how to do this is:
%pre
exec </dev/tty6 >/dev/tty6 2>/dev/tty6
chvt 6
# then execute your command, for example:
whiptail --inputbox "Enter some text..." 10 30
# switch back to the original TTY
chvt1
exec </dev/tty1 >/dev/tty1 2>/dev/tty1
%end
Using this method the whiptail dialog box is correctly rendered in the new TTY, however no interaction can take place with the dialog - for example pressing tab
, rather than switching between the text entry, "Ok", and "Cancel" elements, actually inserts a tab in the text entry box. Similarly, using the arrow keys results in escape sequences being written in the dialog:
This behaviour is also observed when using python snack (uses the same library as whiptail - libnewt) and dialog.
Of course, I could just using an interactive shell script, rather than using whiptail, but I was just wondering if anyone had any suggestions as to why this behaviour is seen, as I would have thought that the only requirements to get this working would be to correctly redirect the input and output streams.
TL;DR
I'm interested in creating a script containing whiptail/dialog commands which can be executed in one TTY and have the output/input of the script go to/come from a different TTY.
Perhaps my question wasn't too clear. I'm interested in creating a script containing whiptail/dialog commands which can be executed in one TTY and have the output/input of the script go to/come from a different TTY. This can be simulated by opening one virtual terminal and trying to (a) switch input/output streams and (b) switch virtual terminals from within a script. Above this is achieved by
exec </dev/tty6 >/dev/tty6 2>/dev/tty6
andchvt 6
respectively. – pxul – 2014-08-13T09:00:47.293