Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Based on Ubuntu core 12.04, I have prepared a bootable DVD. After booting (to console only), I can login as a user and start a script for installation of an embedded device:

sudo install_script

In order to execute this script already at startup, I've added the following to /etc/rc.local in the image of the root filesystem on the DVD:

/bin/bash -ic install_script

Since this script is executed unconditionally, I'd like to give the user some opportunity to bypass installation and get on to a login prompt. To that end, I'd like to use read in the install_script. Unfortunately, the script does not react to keyboard input when run from /etc/rc.local. (There is no problem with the same script started from a shell after login).

How can I get some user input at startup?

(Some thoughts:

  • Maybe, I can somehow detect and connect a tty to read or to the script? I tried /bin/bash -ic install_script </dev/console to no avail.
  • Maybe, there are more suitable options to /bin/bash or to read?
  • Maybe, I could boot into a single shell of a certain user (maybe root, without logging in?) with .bashrc calling sudo install_script (avoiding password check for sudo?)?
  • Maybe, there exists a better place for calling the script?
  • I would not like to separate the interaction (to occur earlier) and the install_script (e.g., by providing different boot options via isolinux and examining /proc/cmdline in the script) for the following reason: Before asking the user, I'd like to examine the system and give an overview of what exactly would happen during the install. At earlier stages of the boot process, the necessary information for the examination of the system may not yet be easily available.


share|improve this question
Hint: posting it here should help you more – Sosi Apr 19 '13 at 12:01
up vote 3 down vote accepted

In my current solution, I'm using openvt to start install_script by adding the following line to \etc\rc.local:

openvt -s -w /path/to/install_script
  • It opens a new virtual terminal (besides the seven others available in Ubuntu Core 12.04 via Alt-F[1-7]).
  • The switch -s tells openvt to switch to the new virtual terminal (without pressing Alt-F8).
  • The Switch -w lets openvt wait for completion of the command /path/to/install_script given to openvt.
  • Started this way, the script can get input from the user as usually by calling read.
  • After the script has finished, the virtual terminal is closed (no more switching to it using Alt-F8) and control is returned to the virtual terminal that was active before.
share|improve this answer
Spent hours on this for building my own LiveCd with remastersys. Your answer FINALLY worked! Using profile.d for this is a BAD idea. Combined with autologin (default in some casper init script (25configure_init) and changed sudoers file for root context, you'll soon find yourself in a hell of multiple executed scripts (for each tty or the initialization of sub-shells [I'm not that sure about the second point]). – Mister Henson May 24 '13 at 14:28

I had them same issue while working on a custom distro for the rasp pi. I found that adding the following code to my script would ensure my script would receive input.

I just call this code before I start reading input:

exec < /dev/tty1
share|improve this answer

just try to imitate Slackware linux install method..

share|improve this answer
More detail is needed to make this a useful answer – Dave M Apr 19 '13 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .