echoed prompt not appearing until after read command.

I have a script I am runing on a hacked CDLinux live CD called from /etc/rc.d/rc.local.

The part of th script in question goes like this.

When run from rc.local the prompt "Centre name :" and the colour change does not appear until after I type the input text and press return. Also, I noticed CTRL-C does not interrupt this script even when it pauses for keyboard input.

When I run the same script after logging from the console it all works as expected with the prompt appearing before the keyboard input.

Sorry if the colour change code isn't relavent here but I have a long debug loop that involves re-burning the CD to test this script in failure mode, so it's probably quicker to post the whole thing just in case.

In a start up script, you are seldom simply talking to a tty device. Instead, you are talking to logging program or psuedo device. It captures the messages and sends them to syslog. Eventually someone along the way sends them to the console as well. It is probably line buffered from your description. You could just line with it. Always send a newline character with every echo. This means your prompt won't be on the same line as the user input. Or you could try to explicitly open the console....
exec > /dev/console 2>&1

assuming your console is called /dev/console.

Yes, that fixed it!

I did a slight variation based on what I found in a Slackware rc.local script.

Not sure if it makes much difference (I have to burn another CD to find out), but I'm happy the script is behaving itself now.

Thanks for helping :slight_smile: