[Balug-talk] Have perl check for a package?

David Hummel ddhummel at pacbell.net
Wed Aug 20 22:17:02 PDT 2003


On Thu, Aug 21, 2003 at 12:16:21AM -0700, qgenuity at qgenuity.com wrote:
> I'm working on a perl script which needs to
> 
> 1) check and see whether a particular package is installed
> and 2) go and fetch it if it is not already there
> 
> Does anyone know how to make perl check to see whether a package is
> installed?

It seems these tasks would be covered by the package manager itself, but
if you're talking about rpm, you can do this:

  $pkg = "mypackage-1.0.0"
  if (system("rpm -q $pkg >/dev/null 2>&1") == 0) {
    print "$pkg is already installed\n";
  } else {
    print "$pkg is not installed\n";
    # go fetch with wget
  }

David Hummel
Genomics & Gene Discovery
WRRC/ARS/USDA



More information about the Balug-talk-balug.org mailing list