Bash scripting on debian installer not accepting user input during pre-section

I have a very small script that should be run on the debian installer: (via preinstall, preinstall script)

echo -n -e " # Your option [1] [2] [3]: "
    read REPLY
    if [ "$REPLY" == "1" ] 

The script stops here, and everything I click is only displayed on the screen, however it does not accept the input key. Usually, when you press 1 and press enter, reading should return 1 in $ REPLY. But nothing happens. It continues to accept user input, but no further action occurs.

Then I switched to tty2 using ALT + F2 and ran the script there, everything was fine, it works as expected when I click; he takes the entrance. Why doesn't tty1 accept input as usual?

+5
source share
4 answers

Use debconf for this configuration, it solves exactly the same needs as yours.

Adapted example from the manual

Template File ( debian/templates):

Template: your_package/select_option
Type: select
Choices: 1, 2, 3
Description: Which option?
 Choose one of the options

Script ( debian/config):

#!/bin/sh -e

# Source debconf library.
. /usr/share/debconf/confmodule

db_input medium your_package/select_option || true
db_go

# Check their answer.
db_get your_package/select_option
if [ "$RET" = "1" ]; then
   # Do stuff
fi
+4
source

Had the same problem (read do not process my input) with busybox on embedded Linux.
It took some time to understand that busybox reading is not CR-tolerant - my terminal program (used by miniterm.py) sent the CR / LF string by default; switching to LF only solved my problem!

+1
source

bash, read:

sh, :

0

script :

#!/bin/sh
echo -n -e " # Your option [1] [2] [3]: "
read

case $REPLY in
    1 ) 
      echo "one" ;;
    2 ) 
      echo "two" ;;
    3 ) 
        echo "three" ;;
    *)
        echo "invalid" ;;
esac

one , 1. , if... fi?

0
source

All Articles