[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: reading user input in %pre script no longer working



On Sep 6, 2007, at 4:55 AM, Steve Robson wrote:

Ben Grommes <ben grommes visionshareinc com> spake thusly:

My kickstart script reads user input in the %pre scriptlet using the read command. This worked fine in CentOS 4.4, but in CentOS 4.5 it no longer works. It appears that the read command is not taking input from the console.
I'm doing a headless mode install (text option in ks.cfg).
Here is my %pre script:
%pre
install="no"
while [ "$install" != "yes" ]; do     (
    echo -n "Proceed with install? "
    )>/dev/tty1
    read install
done
The output of the echo shows up on the screen, but the read command doesn't
accept any input from the keyboard.
Any suggestions for how to debug this would be appreciated.

Try explicitly redirecting stdin as well:

%pre
install="no"
while [ "$install" != "yes" ]; do
    ( echo -n "Proceed with install? " ) >/dev/tty1 </dev/tty1
    read install
done

This is a good suggestion, but based on the symptoms it's more likely that stdin needs to be redirected to the read, rather than the echo. What I would do is either use chvt to change vts and get rid of the redirection entirely, or use exec to redirect for the entirety of the script:

# Method 1 - chvt with no redirection
%pre
chvt 1
install="no"
while [ "$install" != "yes" ]; do
    echo -n "Proceed with install?"
    read install
done
chvt 3 # (or maybe 6, depending on the type of install you are doing)

# Method 2 - redirect the whole script
%pre
exec </dev/tty1 >/dev/tty1 2>/dev/tty1
install="no"
while [ "$install" != "yes" ]; do
	echo -n "Proceed with install?"
	read install
done

# Method 3 - wrap the redirection around the whole loop
%pre
(
	install="no"
	while [ "$install" != "yes" ]; do
		echo -n "Proceed with install?"
		read install
	done
) < /dev/tty1 >/dev/tty1 2>/dev/tty1

--
Jason Kohles
email jasonkohles com
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]