Search code examples
bashunixsolaris

Answer pkgadd prompts using Bash echo


I am trying to silently install a package on Solaris 10 using the pkgadd utility. See example:

pkgadd -G -D pkg123_x64.pkg
"Select package(s) you wish to process (or 'all' to process all packages).

This is resolved by piping with echo to pkgadd:

echo "all" | pkgadd -G -D pkg123_x64.pkg
"Processing package instance <pkg123>.."
"This package contains scripts which will be executed with super-user permission during the process of installing this package. Do you want to continue with the installation [y,n,?]

All OK. But I'm not sure how to answer the second question. I have tried:

echo "all y" | pkgadd -G -D pkg123_x64.pkg

But this does not work. Is this possible?

Using: GNU bash version 3.2.51(1) Solaris 10


Solution

  • You can create a package response file:

    Using a Response File (pkgadd)

    A response file contains your answers to specific questions that are asked by an interactive package. An interactive package includes a request script that asks you questions prior to package installation, such as whether optional pieces of the package should be installed.

    If you know prior to installation that the package is an interactive package, and you want to store your answers to prevent user interaction during future installations, use the pkgask command to save your response. For more information on this command, see pkgask(1M).

    Once you have stored your responses to the questions asked by the request script, you can use the pkgadd -r command to install the package without user interaction.

    From the pkgask man page:

    Description

    pkgask allows the administrator to store answers to an interactive package (one with a request script, that is, a user-created file that must be named request). Invoking this command generates a response file that is then used as input at installation time. The use of this response file prevents any interaction from occurring during installation since the file already contains all of the information the package needs.