I’d like to create a concatenated property of versions/names of of multiple Solaris packages. Each of the packages may or may not exist on each host, e.g.
(if exists pkginfo “package1” of pkgdb then (version of pkginfo “package1” of pkgdb as string & " (package1); ") else “”) & (if exists pkginfo “package2” of pkgdb then (version of pkginfo “package2” of pkgdb as string & " (package2); ") else “”)
would output one of the following-
1.1.1 (package1);
only first package exists
1.1.1 (package1); 1.1.2 (package2);
both packages exist
“”
neither package exists
What I’m struggling with is-
a) how to make the relevance more efficient using ‘it’ and/or ‘whose’ in case the list of packages grows
b) if the end result is null, I’d like to make the output string say something like “not found”. any way to do this without re-checking the existence of each package a second time?
I don’t have a Solaris system handy… but here is the basic form of the relevance that should help:
Using Windows “regapp” (which is analagous to “pkginfo”):
q: (version of it as string & " (" & name of it & “)”) of regapps (“besclient.exe”;“besconsole.exe”;“blah”)
A: 7.1.1.315 (BESClient.exe)
A: 7.1.1.315 (BESConsole.exe)
Or to adapt your relevance for Solaris (untested):
(version of it as string & " (" & name of it & “)”) of pkginfos (“package1”;“package2”;“package3”)
With this relevance, it will return one entry each line… To concatenate them into a single line, use:
q: concatenation “; " of (version of it as string & " (” & name of it & “)”) of regapps (“besclient.exe”;“besconsole.exe”;“blah”)
A: 7.1.1.315 (BESClient.exe); 7.1.1.315 (BESConsole.exe)
In the event that none of these are installed, it should return the normal console string for empty results (something like “”)