in reply to Re^2: Error Handling the Perl script
in thread Error Handling the Perl script
Create an errorlist the same as nodelist
And return the value to mainsub get_node { my ($infile) = @_; my @nodelist = (); my @errorlist = (); ##checks if the file exists and pulls the info out if (-e $infile){ open INFILE, '<', $infile or die "Could not open $infile : $!"; print_log("Scanning $infile"); while (my $node = <INFILE>){ chomp($node); my ($hostname) = split /\./, $node; my $fqdn = getNodeAttributes($hostname,'PrimaryNodeName'); if (length($fqdn) < 1) { print_log("No value returned from WMI, node ($node) doesn't ex +ists in OMW."); push @errorlist,$node; } else { print_log("$node => $hostname => $fqdn"); push @nodelist,$fqdn; } } close INFILE; } else { print_log("ERROR Cannot open $infile"); } return (\@nodelist,\@errorlist); }
and add line after clearing server listmy ($nodelist,$errorlist) = get_node($path.'serverlist.txt');
print_log("There were ".scalar @$errorlist." errors in serverlist");
delete the process_error code.
poj
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Error Handling the Perl script
by shroh (Acolyte) on Aug 14, 2015 at 18:46 UTC |