How to read input while installing Debian package on Debian systems

2.6k views Asked by At

I have created a small Debian package which has to take the input from the user and print it out.

In order to take input from user "read" command on postinst scripts will not work on Debian systems I don't know what is the exact reason, but it worked in Ubuntu systems.

Later I have figured out that we have to use "debconf" for Debian systems by using a template file.

Template file:

Template: test/input
Type: text
Description: enter some text, which will be displayed

postinst script:

 db_get test/input
    echo "you have entered ::$RET" >&2

But when I install my test package I get this error:

Can't exec "postinst": No such file or directory at /usr/share/perl/5.10/IPC/Open3.pm line 168. <br>open2: exec of postinst configure failed at /usr/share/perl5/Debconf/ConfModule.pm line 59

Does anyone know what I have done wrong?

1

There are 1 answers

0
Mih V An On

Your postinst script should look like the following:

#!/bin/bash

set -e

. /usr/share/debconf/confmodule

case "$1" in
  configure)
    db_get test/input
    echo "you have entered ::$RET" >&2
  ;;
esac
db_stop