Subversion Repositories camp_sysinfo_client_3

Rev

Rev 87 | Rev 244 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/usr/bin/env perl
use warnings;
use strict;  

use utf8;                                # Source code encoded using UTF-8

# Description: Get software installed by dpkg or apt(itutde) (Debian)

our $VERSION = '1.2';

# Debian software module for sysinfo client
# Author: R. W. Rodolico
# Date:   2016-04-08

# gets information on software on systems with dpkg on them (Debian)

BEGIN {
   push @INC, shift;
}

use library;

my $dpkg = &validCommandOnSystem( 'dpkg' );
my $grep = &validCommandOnSystem( 'grep' );

exit 1 unless $dpkg && $grep;

my $CATEGORY = 'software';

my @packageList  = split( "\n", qx($dpkg -l | $grep ^i));
chomp @packageList;

for ( my $i = 0; $i < @packageList; $i++ ) {
   utf8::encode( $packageList[$i] );
   my ($status,$package, $version, @description) = split ' ', $packageList[$i];
   print "$CATEGORY\t$package\tversion\t$version\n";
   print "$CATEGORY\t$package\tdescription\t" . join(" ", @description) . "\n";
}