Rev 55 | Rev 117 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/usr/bin/env perl
use warnings;
use strict;
# Description: Library used by modules. Do NOT enable
our $VERSION = '1.2';
# set of libraries to be used by these modules
# cleanUp - passed a delimiter and a string, does the following (delimiter can be '')
# chomps the string (removes trailing newlines)
# removes all text BEFORE the delimiter, the delimiter, and any whitespace
# thus, the string 'xxI Am x a weird string' with a newline will become
# 'a weird string' with no newline
sub cleanUp {
my ($delimiter, $text) = @_;
chomp $text;
return $text unless $delimiter;
$text =~ m/[^$delimiter]*$delimiter\s*(.*)/;
return $1;
}
# checks if a command is valid on this system. If so, returns the full path to it
# else, returns empty string.
sub validCommandOnSystem {
my $command = shift;
$command = `which $command 2> /dev/null`;
chomp $command;
return -x $command ? $command : '';
}
sub getOperatingSystem {
return &cleanUp('', qx(uname -s));
}
sub getSysctlParameter {
my ( $sysctl, $parameter ) = @_;
my $result = qx( $sysctl $parameter );
chomp $result;
$result =~ s/$parameter:\s*//;
return $result;
}
1;