Subversion Repositories camp_sysinfo_client_3

Rev

Rev 233 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 233 Rev 251
Line 12... Line 12...
12
# Author: R. W. Rodolico
12
# Author: R. W. Rodolico
13
# Date:   2016-04-08
13
# Date:   2016-04-08
14
 
14
 
15
# gets information on software on systems with dpkg on them (Debian)
15
# gets information on software on systems with dpkg on them (Debian)
16
 
16
 
-
 
17
# find our location and use it for searching for libraries
17
BEGIN {
18
BEGIN {
18
   push @INC, shift;
19
   use FindBin;
-
 
20
   use File::Spec;
-
 
21
   use lib File::Spec->catdir($FindBin::Bin);
-
 
22
   eval( 'use library;' ); die "Could not find library.pm in the code directory\n" if $@;
-
 
23
   eval( 'use Data::Dumper;' );
19
}
24
}
20
 
25
 
21
use library;
26
# check for valid OS. 
-
 
27
exit 1 unless &checkOS( { 'linux' => undef } );
22
 
28
 
-
 
29
# check for required commands, return 2 if they don't exist. Enter an full list of all commands required. If one doesn't exist
-
 
30
# script returns a 2
23
my $dpkg = &validCommandOnSystem( 'dpkg' );
31
foreach my $command ( 'dpkg', 'grep' ) {
24
my $grep = &validCommandOnSystem( 'grep' );
32
   exit 2 unless &validCommandOnSystem( $command );
25
 
33
}
26
exit 1 unless $dpkg && $grep;
-
 
27
 
34
 
28
my $CATEGORY = 'software';
35
my $CATEGORY = 'software';
29
 
36
 
30
my @packageList  = split( "\n", qx($dpkg -l | $grep ^i));
37
my @packageList  = split( "\n", qx(dpkg -l | grep ^i));
31
chomp @packageList;
38
chomp @packageList;
32
 
39
 
33
for ( my $i = 0; $i < @packageList; $i++ ) {
40
for ( my $i = 0; $i < @packageList; $i++ ) {
34
   utf8::encode( $packageList[$i] );
41
   utf8::encode( $packageList[$i] );
35
   my ($status,$package, $version, @description) = split ' ', $packageList[$i];
42
   my ($status,$package, $version, @description) = split ' ', $packageList[$i];