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!)

Recommended Answers

All 6 Replies

Have you tried removing the semi-colon after the first line and tried running it that way?

In my experience, I only put a semi-colon there if the do will be put on the same line. I think that is unnecessary - let me know how that works out, because other than that it looks good to me.

Looks pretty solid.

Possibly try changing the variable ANSWER to something goofy, like BORG, just in case ANSWER is special (like REPLY).

Best wishes,

Mike

Thanks for reply!

However, I still got no luck by removing the semi-colomn and change the variable name!

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.

Wow,

I feel pretty dumb right now ;) I should have known that... Now that I think back, I never have had to answer any questions post-install, it was always pre-install...

Life surprises you sometimes. I think we overthought this one and the answer was simple once you relaxed and let it come to ya.

Good job :)

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.