1832853 Members
2919 Online
110047 Solutions
New Discussion

Search for software

 
SOLVED
Go to solution
UniRock
Regular Advisor

Search for software

Hello All,

I have a number of servers A,B,C etc which have number of depots.
I want to search these servers for a particular software (that I need to install on another test server)

# swlist -l depot -s abc.efg.xyz.com
---shows lists of depots---
/var/spool/sw/PHSS_30724.depot
/var/spool/sw/11i_PA.apps <<===
/var/spool/sw/es_maint
/var/spool/sw/cvsdm_11_11_v10800
---shows lists of depots---

But these depot/directories will in turn have a number of softwares.

# swlist -l product -s abc.efg.xyz.com:/var/spool/sw/11i_PA.apps
--------------
--------------
MeasureWare C.03.72.00 MeasureWare Software/UX
MeasurementInt C.03.72.00 HP-UX Measurement Interface for 11i
Mozilla 1.4.0.00.00 Mozilla 1.4
MozillaSrc 1.4.0.00.00 Mozilla 1.4 Source Distribution
NetscapeDirSvr6 B.06.11 The Netscape Directory Server v6
NisLdapServer B.03.10 The NIS/LDAP Gateway (ypldapd)
--------------
--------------

So, how can I search for a particular software using least number of commands, if possible.

I will be doing all these activities from my test server.

Thanks in advance..

7 REPLIES 7
Dennis Handly
Acclaimed Contributor

Re: Search for software

>how can I search for a particular software using least number of commands

If you know the name of the software, you don't have to list all products.

So of you have S servers and each has D' depots and each has P' products, you need two nested for/while loops.

for S in $(< list-of-servers); do
swlist -l depot -s $S | while read D; do
swlist -l product -s $S:$D
# if you find what you want, you can use "break 2"
done
done
UniRock
Regular Advisor

Re: Search for software

Hello Dennis,

The script is pulling things good..

Script is:
----------------
for S in xxxx.xxx.xx.com yyyy.yyy.yy.com ; do
swlist -l depot -s $S | while read D; do
swlist -l product -s $S:$D
done
done
----------------

# ./script1 | grep -i cifs

----Output truncated----

ERROR: There is currently no depot software on host
"yyyy.yyy.yy.com" at location "/abcd/depot". Make sure that
an absolute pathname is specified for location (beginning with
"/").
ERROR: More information may be found in the daemon logfile on this
target (default location is
xxxx.xxx.xx.com:/var/adm/sw/swagentd.log).
CIFS-Development A.01.09.04 CIFS/9000 server source code files
CIFS-Server A.01.09.04 CIFS/9000 (Samba) File and Print Services
CIFS-Client A.01.08 HP CIFS/9000 Client
ERROR: There is currently no depot software on host
"xxxx.xx.xx.com" at location "/tmp/iether.depot". Make sure
that an absolute pathname is specified for location (beginning
with "/").

Points of concern:
1. This script is pulling out results but with hhuuggee number of ERROR lines.
2. Another thing is that I am unable to get the path of the software pulled by the script.

Any solution for this?
Thanks..
James R. Ferguson
Acclaimed Contributor

Re: Search for software

Hi:

> 1. This script is pulling out results but with hhuuggee number of ERROR lines.

Like all well-behaved software allows, redirect STDERR to /dev/null :

...
swlist -l depot -s $S 2>/ dev/null | while read D; do
swlist -l product -s $S:$D 2> /dev/null
...


> 2. Another thing is that I am unable to get the path of the software pulled by the script.

If you want this than you will have to descend to the file level:

# swlist -l file

Regards!

...JRF...
UniRock
Regular Advisor

Re: Search for software

Hi Again..

>I am unable to get the path of the software pulled by the script.

By this I mean that I cannot get the path where the software depot is placed on the server.
In other words..I have mentioned three servers to search for a particular software. Script pulls out the software but how do I know where this software is placed and on which server??

BTW, redirection works nice.

Thanks..
Dennis Handly
Acclaimed Contributor
Solution

Re: Search for software

>1. This script is pulling out results but with hhuuggee number of ERROR lines.

Oops, I did some hand waving and didn't test it. There were comment lines.

This should work better, unless you have depots you registered but used rm to remove:
for S in xxxx.xxx.xx.com yyyy.yyy.yy.com ; do
swlist -l depot -s $S | grep -v "^#" |
while read D; do
swlist -l product -s $S:$D
done
done

>but how do I know where this software is placed and on which server?

You need to grep for two patterns:
# ./script1 | grep -i -e Internet -e Target:
# Target: XXX:/tmp/depot
# Target: XXX:/var/tmp/InternetSrvcs.11_23
InternetSrvcs B.11.23 General network applications and daemons
UniRock
Regular Advisor

Re: Search for software

Hi Dennis,

If have edited the script to:
-----------------------------
echo "Enter the name of the software to search for: "
read P
for S in casea.cup.hp.com hpindml.cup.hp.com vick2.atl.hp.com; do
swlist -l depot -s $S 2> /dev/null | while read D; do
swlist -l product -s $S:$D 2> /dev/null | grep -v "# Contacting" | grep -i -e $P -e target
done
done
-----------------------------

And it is working perfect as I wished.
Thanks again Dennis for your help..
Dennis Handly
Acclaimed Contributor

Re: Search for software

>If have edited the script to:

You really should keep my grep between the first swlist and the "while". No need to make swlist sweat by looking up "#" names.