All,
Please audit my code as I cannot figure out the correct method to pass by
ref into my logroll subroutine.
Here is the error I am getting :
Uncaught exception from user code:
error: can not lock open: ($_) at
/usr/local/bin/ohiohealth/tapesz_chk.OH.pl line 115
Carp::croak('error: can not lock open: ($_)') called at
/usr/perl5/site_perl/5.6.1/Logfile/Rotate.pm 3
Logfile::Rotate::new('Logfile::Rotate', 'File', '$_', 'Count', 10,
'Gzip', '/usr/bin/gzip', 'Dir', ..5
main::logroll('/usr/local/log/fuji_tapeszs.log') called at
/usr/local/bin/ohiohealth/tapesz_chk.OH.pl
#######################################
## Set pragmas and modules (LC/UC) ##
#######################################
use strict;
use warnings;
use diagnostics;
use MIME::Lite;
use Logfile::Rotate;
$ENV{"PATH"} = qq(/opt/SUNWsamfs/sbin:/usr/bin:/usr/sbin:/usr/local/log);
my $wd=40;
my $tpexports = qq(/usr/local/log/exports);
my $hrtlabtapeszs = qq(/usr/local/log/heartlab_tapeszs.log);
my $fujitapeszs = qq(/usr/local/log/fuji_tapeszs.log);
my $slhtapeszs = qq(/usr/local/log/slh_tapeszs.log);
open (FFFF_, "+>$tpexports") || die "could not open file: $tpexports $!";
open (FFF_, "+<$hrtlabtapeszs") || die "could not open file: $hrtlabtapeszs
$!";
open (FF_, "+<$fujitapeszs") || die "could not open file: $fujitapeszs $!";
#open (F_, "+<$slhtapeszs") || die "could not open file: $slhtapeszs $!";
system("archiver -lv|egrep 'sf.H02[0-9][0-9][0-9]' > $hrtlabtapeszs");
system("archiver -lv|egrep 'sf.F02[0-9][0-9][0-9]' > $fujitapeszs");
#system("archiver -lv|egrep 'sf.L02[0-9][0-9][0-9]' > $slhtapeszs");
select( (select(FFFF_), $|=1 ) [0] );
open (FFF_, "+<$hrtlabtapeszs") || die "could not open file: $hrtlabtapeszs
$!";
open (FF_, "+<$fujitapeszs") || die "could not open file: $fujitapeszs $!";
#open (F_, "+<$slhtapeszs") || die "could not open file: $slhtapeszs $!";
system("archiver -lv|egrep 'sf.H02[0-9][0-9][0-9]' > $hrtlabtapeszs");
system("archiver -lv|egrep 'sf.F02[0-9][0-9][0-9]' > $fujitapeszs");
#system("archiver -lv|egrep 'sf.L02[0-9][0-9][0-9]' > $slhtapeszs");
select( (select(FFFF_), $|=1 ) [0] );
select( (select(FFF_), $|=1 ) [0] );
select( (select(FF_), $|=1 ) [0] );
#select( (select(F_), $|=1 ) [0] );
while (<FFF_>) {
if (substr($_, 52, 5) == 0 ){
chomp $_;
my $hvalustr=substr($_, 52, 5);
my $htpstr=substr($_, 2, 9);
system("samexport $htpstr");
# &logroll($hrtlabtapeszs);
print FFFF_ "$htpstr\t$hvalustr\n";
}
}
while (<FF_>) {
if (substr($_, 52, 5) == 0 ){
chomp $_;
my $fvalustr=substr($_, 52, 5);
my $ftpstr=substr($_, 2, 9);
#system("samexport $ftpstr");
&logroll($fujitapeszs.);
###- - -### possible coding errors
print FFFF_ "$ftpstr\t$fvalustr\n";
}
}
#while (<F_>) {
# if (substr($_, 52, 5) == 0 ){
# chomp $_;
# my $svalustr=substr($_, 52, 5);
# my $stpstr=substr($_, 2, 9);
# system ("samexport $stpstr");
# &logroll($slhtapeszs);
# print FFFF_ "$stpstr\t$svalustr\n";
# }
#}
if ( -s $tpexports ) {
print FFFF_ "\n",'-' x $wd, "\n";
print FFFF_ "TapeID\t BytesRemaining\n\n";
print FFFF_ "Please eject these as offsite
permanent!\nOhioHealth Unix Support";
#&mailme;
#&logroll;
}
sub mailme {
my $msg = MIME::Lite->new(
From => 'stkv440 <xxxxxxxxxxx>',
#To => 'OHIS Operations <xxxxxxxxx>',
To => 'Derek Smith <xxxxxxxx>',
Subject => "ASM Copy 2 exports",
Type => 'multipart/related');
$msg->attach(
Type => 'TEXT',
Path => "$tpexports",
Filename => "$tpexports");
$msg->send;
}
#foreach ($fujitapeszs,$hrtlabtapeszs,$tpexports,$slhtapeszs) {
#if ( -s $_ or -s $_ or -s $_ or -s $_ ) {
#foreach ($_) {
sub logroll {
my $logs = new Logfile::Rotate
(File => '$_',
###- - - ### possible coding error
Count => 10,
Gzip => '/usr/bin/gzip',
Dir =>
'/usr/local/log/old',
Flock => 'yes',
Persist => 'yes' );
$logs->rotate($_);
###- - -### possible code eror
}
#}
#}
#}
#close (F_) or warn "unable to close file $!";
close (FF_) or warn "unable to close file $!";
close (FFF_) or warn "unable to close file $!";
close (FFFF_) or warn "unable to close file $!";
__DATA__
sf.F02002 capacity: 189.1G space: 0 -il-o-b-----
2 archive sets have no volumes available
sf.F02005 capacity: 189.1G space: 123.4G -il---b-----
sf.F02006 capacity: 189.1G space: 92.7G -il-o-b-----
sf.F02007 capacity: 60.0G space: 59.9G -il-o-b-----
sf.F02008 capacity: 60.0G space: 59.9G -il-o-b-----
sf.F02009 capacity: 60.0G space: 59.9G -il-o-b-----
sf.F02010 capacity: 60.0G space: 59.9G -il-o-b-----
sf.F02011 capacity: 60.0G space: 59.9G -il-o-b-----
sf.F02012 capacity: 60.0G space: 59.9G -il-o-b-----
thank you!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>