954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

kingpmp
Newbie Poster
4 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

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.

omrsafetyo
Junior Poster in Training
58 posts since Apr 2008
Reputation Points: 13
Solved Threads: 9
 

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

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

Thanks for reply!

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

kingpmp
Newbie Poster
4 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

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!

kingpmp
Newbie Poster
4 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

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.

kingpmp
Newbie Poster
4 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

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

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You