This worked for me (Anaconda, Fedora 20):
%pre --log=/tmp/ks_pre.log #!/bin/bash # Backup fds in temporal ones exec >&1 exec >&2 # Go to current terminal for pre% section exec 1>>/dev/pts/0 exec 2>>/dev/pts/0 # Show message whiptail --yesno 'Do you like StackOverflow?' --yes-button 'Yes' --no-button 'No' 10 70 if [ $? = 1 ] then echo 'User sucks' >> /tmp/ks_pre.log else echo 'User rocks' >> /tmp/ks_pre.log fi # Restore fds exec 1>&$STDOUTBACK exec 2>&$STDERRBACK # Close temporal fds exec >&- exec >&- %end
Possible questions:
Why did you use
/dev/pts/0
?Because from the Anaconda console I found out what device was being used as stdin for the scripts running in the
pre% section
. I guess, it could be another one depending on the RedHat and Fedora versions. But it is really easy to find out which is the correct one for your case.What are the
exec >&1
andexec >&-
things?Go to read your
man bash
and search for theREDIRECTION
section, where you can find the following:
Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form . In this case, for each redirection operator except >&- and <&-, the shell will allocate a file descriptor greater than 10 and assign it to varname. If >&- or <&- is preceded by, the value of var‐ name defines the file descriptor to close.