From 1482b1a420a87cac2f4c8980662c47137b710ca1 Mon Sep 17 00:00:00 2001 From: dataking Date: Wed, 28 Jun 2017 23:41:15 -0700 Subject: [PATCH] added sho_version() to assist in troubleshooting. --- lynis-report-converter.pl | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/lynis-report-converter.pl b/lynis-report-converter.pl index 85f282d..52101ac 100755 --- a/lynis-report-converter.pl +++ b/lynis-report-converter.pl @@ -12,7 +12,7 @@ use Getopt::Long qw( :config no_ignore_case bundling ); use Data::Dumper; use Module::Load::Conditional qw( can_load check_install requires ); -my ($help,$verbose,$excel,$output,$pdf,$debug,$json,$quiet,$xml); +my ($help,$verbose,$excel,$output,$pdf,$debug,$json,$quiet,$xml,$showversion); GetOptions( 'h|help' => \$help, 'v|verbose+' => \$verbose, @@ -23,10 +23,11 @@ GetOptions( 'j|json' => \$json, 'x|xml' => \$xml, 'q|quiet' => \$quiet, + 'V|version' => \$showversion, ); &usage if ($help); -&usage if ((!$output) and (!$json)); +&usage if ((!$output) and (!$json) and (!$showversion)); #if ($verbose) { use warnings; } @@ -190,6 +191,10 @@ if (exists($lynis_report_data{'tests_executed'})) { delete($lynis_report_data{'tests_executed'}); } +if ($showversion) { + &show_version; +} + if ($debug) { print colored("In debug mode. Dumping data hash.\n", "yellow"); print color('yellow'); @@ -2342,7 +2347,7 @@ if ($verbose) { ############################################################################### sub usage { - if (!$output) { + if ((!$output) and (!$showversion)) { print colored("You must specify an output file.\n", "yellow"); } @@ -2364,6 +2369,25 @@ END exit 0; } +# show script version and gather some relevant data for troubleshooting +sub show_version { + my $uname_a = `uname -a`; + chomp($uname_a); + my $perl_v = `perl --version`; + chomp($perl_v); + print <