Hi Guys
I am having a perl script that fetches exclude list from a unix client and I trying it to convert it to shell script but I am having issues please help me...
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
# To turn on debuging (i.e. more information) specify -d on the command line
our $opt_d = 0;
# To get ONLY the version information specify -v on the command line
our $opt_v = 0;
getopts('dv');
our $debug = $opt_d;
my $uname = `uname -n`;
chomp $uname;
# Desiginate where to write the in/exclude files (must be fully qualified path)
our $PWD = $ENV{PWD};
our $output_dir = "$PWD/EI_${uname}";
if ( ! -d $output_dir ) { mkdir $output_dir }
# Location of bp.... commands
our $nbadmin = "/usr/openv/netbackup/bin/admincmd";
# Generate a list of policies
our @policy_list = `$nbadmin/bppllist`;
# Used the get output of the bpgetconfig command. Only need for debut purposes
our @status = ();
foreach my $policy (@policy_list) {
chomp $policy;
# Get the individual policy information
my @policy = `$nbadmin/bppllist $policy -l`;
# Extract the info line
my @info = grep /^INFO /, @policy;
# If the policy type is not standard, ignore
if ( (split /\s+/, $info[0])[1] != 0 ) { next }
# If the policy is inactive, ignore
if ( (split /\s+/, $info[0])[11] != 0 ) { next }
# Pull out the clients for this policy and then keep only the client names
my @clients = grep /^CLIENT /, @policy;
@clients = map { (split /\s+/, $_)[1]} @clients;
# Pull out the schedules for this policy and then keep only the schedule names
my @schedules = grep /^SCHED /,@policy;
@schedules = map { (split /\s+/, $_)[1]} @schedules;
# Now for each client
foreach my $client (@clients) {
if ($debug != 0) { print STDERR "$client $policy\n"; }
# Be sure the client is at leas pingable otherewise the bpgetconfig command will take a long time to fail
system("ping -c 1 -W 5 $client > /dev/null 2>&1");
if ($? != 0 ) { print STDERR "$client not pingable\n"; next }
open VERSION, ">$output_dir/version.$client" or die "Couldn't open $output_dir/version.$client for output: $!\n";
print VERSION "============= Version Check of $client ===================\n";
print VERSION `bpgetconfig -t -A -g $client 2>&1`;
print VERSION "============= End Version Check of $client ===================\n";
close VERSION;
if ( ! $opt_v ) {
# get, if any, the basic include and/or exclude files. (i.e. /usr/openv/netbackup/exclude_list or include_list)
@status = `$nbadmin/bpgetconfig -e \"/$output_dir/exclude.$client.basic\" \"$client\" 2>&1`;
if ($? != 0 && $debug != 0 ) { print STDERR "$client bpgetconfig -exclude no policy failed with $?\n @status" }
@status = `$nbadmin/bpgetconfig -i \"/$output_dir/include.$client.basic\" \"$client\" 2>&1`;
if ($? != 0 && $debug != 0 ) { print STDERR "$client bpgetconfig -include no policy failed with $?\n @status" }
# get, if any, the policy include and/or exclude files. (i.e. /usr/openv/netbackup/exclude_list.policy or include_list.policy)
@status = `$nbadmin/bpgetconfig -e \"/$output_dir/exclude.$policy.$client\" \"$client\" \"$policy\" 2>&1`;
if ($? != 0 && $debug != 0 ) { print STDERR "$client bpgetconfig -exclude policy only failed with $?\n @status" }
@status = `$nbadmin/bpgetconfig -i \"/$output_dir/include.$policy.$client\" \"$client\" \"$policy\" 2>&1`;
if ($? != 0 && $debug != 0 ) { print STDERR "$client bpgetconfig -include policy only failed with $?\n @status" }
# Now for each schedule in the policy (i.e. /usr/openv/netbackup/exclude.policy.schedule=
foreach my $schedule (@schedules) {
if ($debug != 0) { print STDERR "$client $policy $schedule\n"; }
@status = `$nbadmin/bpgetconfig -e \"/$output_dir/exclude.$policy.$client.$schedule\" \"$client\" \"$policy\" \"$schedule\" 2>&1`;
if ($? != 0 && $debug != 0 ) { print STDERR "$client bpgetconfig -exclude with policy and schedule failed with $?\n @status" }
@status = `$nbadmin/bpgetconfig -i \"/$output_dir/include.$policy.$client.$schedule\" \"$client\" \"$policy\" \"$schedule\" 2>&1`;
if ($? != 0 && $debug != 0 ) { print STDERR "$client bpgetconfig -include with policy and schedule failed with $?\n @status" }
}
}
}
# If any of the bpgetconfigs work the ouput will be in the file name following the -e or -i
}
exit;
====================== End of code ========================