Link to home
Start Free TrialLog in
Avatar of alanlam123
alanlam123

asked on

Perl script

Hi expert

good day

Is there any example for reference that was generate in perl script to capture patching result or generate report.  

such as capture result to capture for the folowing;

Get yum report for Errata info - yum list-sec --security

Get yum list update packages-- yum list updates --security

exclude in vi/etc/yum.conf ( to get information before patch)

yum list-sec --security

yum list updates --security

Get List of updates packages

yum list updates --security

Get installed packages

yum list installed

Get Errata CVE and relate info

yum updateinfo info --security |grep "Update | D\|CVE\|Severity"

The end result will show in the attachment.
Patching-report-sample.xlsx
Avatar of alanlam123
alanlam123

ASKER

Hi Expert

Need some help how to execute yum update --security if I intend use perl script.

I believed some of the missing variable, i use the following script.

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


yum update --security
print "completed\n" ;
Avatar of noci
yum is not a perl statement:

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


my @cmd=("yum", "update" "--security");
my $yumstatus = system @mycmd;
print "completed\n" ;

Open in new window

See man perlfunc and look for 'system LIST'

the other way is: using backticks: (man perlop search for qx//)

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


my $yumoutput = `yum update --security`;
print "completed\n" ;

Open in new window

Hi expert

i encountered the following errors show in the following;

syntax error at ./test9.pl line 7, near "print"
Execution of ./test9.pl aborted due to compilation errors.

i use the above script;

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


my $yumoutput = `yum update --security`
print "completed\n" ;
Aaargh.. ; missing...

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


my $yumoutput = `yum update --security`;
print "completed\n" ;

Open in new window


(i have no CentOS/RHEL to test this on... , gentoo doesn;t use yum..., so didn't check enough).
Updated other examples as well.
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks