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:
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.
0-9000.x86_64.pkg>
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.
Shell ScriptingScripting LanguagesUnix OS
Last Comment
sunhux
8/22/2022 - Mon
sunhux
ASKER
The inputs I entered in the above series of steps are:
Sorry I missed pkgrm : it prompts for question & I tried the following
(extracted fr above link)
which did not work:
pkgrm $PACKAGE << EOF
y
y
y
EOF
jmcg
The recipes shown in that unix.com article should work, but if they are failing, it is likely because the package is not entirely following the standards. You could try
It'll prompt twice for "y" but even that, below won't work
pkgrm $PACKAGE << EOF
y
y
EOF
sunhux
ASKER
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
/var/tmp
sunhux
ASKER
I manually created the response file but pkgadd still prompts :
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
jmcg
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.
sunhux
ASKER
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.
sunhux
ASKER
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
1. all
2. y