Script/ways to automate pkgadd which prompts for y / yes / all

I have hundreds of Solaris 10 VMs which I need to do "pkgrm" & "pkgadd"
& I could issue these commands centrally from a central location instead
of login one by one which makes it much faster for me.

However, the commands won't work if being prompted for inputs
like y or yes or all as shown below.  Is there any option to pkgrm &
pkgadd so that it doesn't prompt for these?

If not, appreciate some sort of scripts (but not Expect TCL script as I'm
not allowed to install these; besides I cant find Expect TCL pkg for
Solaris x86) to facilitate this will be nice:

# pkgadd -d ./Agent-_5.10_US-9.0.0-9000.x86_64.pkg

The following packages are available:
  1  ms-agent     MicroFocus Agent
                  (x86_64) 9.0.0-9000

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: all

Processing package instance <ms-agent> from </var/tmp/Agent-Solaris_5.10_US-9.0.

MicroFocus MSSS Agent(x86_64) 9.0.0-5000
Copyright (c) 2004-2012 MicroFocus Inc.
All rights reserved.
## Executing checkinstall script.
Using </> as the package base directory.
## Processing package information.
## Processing system information.
   8 package pathnames are already properly installed.
## Verifying package dependencies.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

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 of <ms-agent> [y,n,?] y

Installing MicroFocus MSSS Agent as <ms-agent>

## Executing preinstall script.
## Installing part 1 of 1.

## Executing postinstall script.

Installation of <ms-agent> was successful.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sunhuxAuthor Commented:
The inputs I entered in the above series of steps are:

1. all
2. y
This link describes how to automate package installation for Solaris:

Performing unattended installation on Solaris []

It's part of the StorageVault installation documentation, but the general idea should work for other packages.

The main thing to note is the -r flag specifying a response file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunhuxAuthor Commented:
So I'll need to run  'pkgask ...'  first then followed by 'pkgadd ...' ?

pkgask -r <response file>  ./pkg_name
pkgadd -n -a <admin file> -d <device> -r <response file> <package>

So I don't need "-n -a <adminFile>"   in my case?
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

sunhuxAuthor Commented:
any idea if there's something equivalent for RHEL5 & RHEL6 ?
I believe you only need to run pkgask if you don't already know what responses are needed.

On RHEL, I think you'd be using either rpm or yum, but I'm not a Red Hat user. There is a -y flag for yum that means "answer 'yes' to every question", but I didn't see anything equivalent to a prepared response file.
sunhuxAuthor Commented:

Sorry I missed pkgrm : it prompts for question & I tried the following
(extracted fr above link)
which did not work:

pkgrm $PACKAGE << EOF
The recipes shown in that article should work, but if they are failing, it is likely because the package is not entirely following the standards. You could try

pkgrm -A $PACKAGE

Open in new window

Ultimately, the expect program could automate interaction with even non-standard packages, but that's a lot of work to go through.
sunhuxAuthor Commented:
I can't install  "expect" package (any way, I can't locate  'expect' for Solars x86 Ver 10 anywhere anymore).

"pkgrm -A"  still prompts for y/n :

-bash-3.2# pkgrm -A ds-agent

The following package is currently installed:
   ds-agent  Microfocus DS Agent
             (x86_64) 8.0.0-2004

Do you want to remove this package? [y,n,?,q] ^C
1 package was not processed!

-bash-3.2# pkgrm -n ds-agent

This package contains scripts which will be executed with super-user
permission during the process of removing this package.

Removal of <ds-agent> was suspended (interaction required).
No changes were made to the system.
sunhuxAuthor Commented:
It'll prompt twice for "y" but even that, below won't work

pkgrm $PACKAGE << EOF
sunhuxAuthor Commented:
pkgask runs into issue:

-bash-3.2# pkgask -r /var/tmp/rsp ./Agent-Solaris_5.10_U7-9.0.0-5000.x86_64.pkg
pkgask: ERROR: no package associated with <./Agent-Solaris_5.10_U7-9.0.0-5000.x86_64.pkg>
-bash-3.2# ls -lad rsp
rsp: No such file or directory
-bash-3.2# pwd
sunhuxAuthor Commented:
I manually created the response file but pkgadd still prompts :

-bash-3.2# pkgadd -d ./Agent-Solaris_5.10_U7-9.0.0-5000.x86_64.pkg -r /var/tmp/rsp

The following packages are available:
  1  ds-agent     Trend Micro Deep Security Agent
                  (x86_64) 9.0.0-5000

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:  ^C

-bash-3.2# cat rsp
sunhuxAuthor Commented:

Link above described the problem I faced very well:

"yes | pkgrm [package-name]" works because all the answers should be 'y' .

"pkgrm somesoftware < infile"  doesn't work because 1st answer is  "all" & 2nd answer is "y"
ie not all answers are the same
Aside from suggesting that perhaps the "-r /var/tmp/rsp" should come earlier in the command line, I'm afraid I have little else to help you. It seems that things do not work as documented (not that I could be sure the documentation applied to your version of Solaris in the first place). You may need to ask again to see if you can attract the attention of an Expert who has more direct knowledge of how your particular system works.
sunhuxAuthor Commented:
No worry, you've been very responsive & helpful;  much appreciated.

What you suggest so far got me encouraged & set me thinking & now
I got all my answers & could do a mass pkgrm & pkgadd on a few
hundred servers centrally;  what finally works are as follows:

 yes | pkgrm pkgname
 echo y |pkgadd -d ./packagename.pkg all
If the yes command works for pkgrm, it would have expected it to work for your pkgadd command as well. All it does is supply an endless stream of "y" responses as long as the pipe is neither blocked or closed. But if you have something that works, I should just congratulate you.
sunhuxAuthor Commented:
I only need to input "yes" to all pkgrm prompts whereas for pkgadd, it's a mix
of "all" & "y" thus yes wouldn't work for pkgadd
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.