rc.local with read will not echo key strokes

I’m using CentOS 6.4 and have a small problem with using read in /etc/rc.local file. It will allow keyboard entry but does not echo any of the key strokes during input. This is something that worked fine in CentOS 5.5.

Anyone know what’s going on here?

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
echo -n "name? "
read name
echo "Name: $name"
touch /var/lock/subsys/local

produces (/var/log/boot.log):

name? Name: john

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

I wonder if this is your issue?

I found this CentOS forum thread titled: [SOLVED] User input during rc.local?.

excerpt of problem

I’m attempting to mount an encrypted drive during the execution of the rc.local file. It prompts for a password, but upon the second keypress, it appears to be receiving a crlf (or whatever) and attempts to unlock the drive – failing, since I wasn’t silly enough to encrypt it with a two character passcode.

To which the apparent answer is to disable plymouth first.

You cannot run interactive scripts from rc.local unless you first run ‘plymouth quit’.

What’s Plymouth?

excerpt from Freedesktop.org

Plymouth is an application that runs very early in the boot process (even before the root filesystem is mounted!) that provides a graphical boot animation while the boot process happens in the background.

It is designed to work on systems with DRM modesetting drivers. The idea is that early on in the boot process the native mode for the computer is set, plymouth uses that mode, and that mode stays throughout the entire boot process up to and after X starts. Ideally, the goal is to get rid of all flicker during startup.

Solving your issue

So I believe all you’d need to do is prior to running your read command is to make use you put in rc.local the command:

plymouth quit

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply