Package post-install script problem

I wrote a post-install script, which is executed after the package installation by command like " pkgadd -d /mypackage.pkg".

I also want to read user input in post-install script as follows:

  while [ "$ANSWER" != "y" -a "$ANSWER" != "n" ] ;
  do
     echo "Apply changes to database? [y/n]:"
     read ANSWER
  done

However, it does NOT pause and wait for user input at all! Instead, it goes into an infinite loop:

Apply changes to database? [y/n]:
Apply changes to database? [y/n]:
Apply changes to database? [y/n]:
Apply changes to database? [y/n]:
Apply changes to database? [y/n]:
...

Any advice will be appreciated!

By the way, if I run the script separately, everything is fine!

I'm not familiar with pkgadd but it looks like it's running the script with input redirected from /dev/null. The recommendation for package installation scripts is to avoid user interaction, anyway. I'd suggest you avoid this dialog altogether; if it's absolutely necessary, I'm imagining the pkgadd documentation will have suggestions for how to properly engage the administrator in a dialogue (probably even before this script runs).

Thanks era.

I went through pkgadd and pkgmk documentation and got no answer for this, unfortunately!

After disucssion with my colleague, we came up with an idea - read the user input from a jar then return to shell script.

It works!

My mistake! It still doesn't work!

According to Solaris packaging documentation, the only place, which the installer can solicit user input, is through "request script". That's a stage far before post-install.

Yes, you just need to pass the result to the post-install script somehow.