grazinggoat
Programmer
Happy New Year Guru's! 
I am having a problem with my script renaming/moving files
the move() and also tried rename() doesn't seem to like the .gz
after i compress the file. when i run the script it gives
A.log20120118053018PSTgz
Any thoughts?
Here is what I am doing:
$A_Log = "$A.log";
$B_Log = "$B.log";
my @files = ( $A_Log, $B_Log );
foreach $logFile (sort(@files)) {
chomp($logFile);
print "$logFile\n"; #debug
if ( -e $logFile ) {
$fsize = (stat($logFile))[7];
if ( $fsize >= 5000000 ) {
system("/bin/gzip -9 $logFile");
print "$logFile\n"; #debug
move( $logFile.gz, $logFile.(strftime '%Y%m%d%H%M%S%Z', localtime time).gz ) or die "Could not move gzip'd file $logFile: $!\n";
print "info: $logFile compressed and moved...\n";
}
else {
print "info: $logFile does not need to be moved...\n";
}
}
else {
print "info: $logFile does not exist\n";
}
} # End foreach Loop
I am having a problem with my script renaming/moving files
the move() and also tried rename() doesn't seem to like the .gz
after i compress the file. when i run the script it gives
A.log20120118053018PSTgz
Any thoughts?
Here is what I am doing:
$A_Log = "$A.log";
$B_Log = "$B.log";
my @files = ( $A_Log, $B_Log );
foreach $logFile (sort(@files)) {
chomp($logFile);
print "$logFile\n"; #debug
if ( -e $logFile ) {
$fsize = (stat($logFile))[7];
if ( $fsize >= 5000000 ) {
system("/bin/gzip -9 $logFile");
print "$logFile\n"; #debug
move( $logFile.gz, $logFile.(strftime '%Y%m%d%H%M%S%Z', localtime time).gz ) or die "Could not move gzip'd file $logFile: $!\n";
print "info: $logFile compressed and moved...\n";
}
else {
print "info: $logFile does not need to be moved...\n";
}
}
else {
print "info: $logFile does not exist\n";
}
} # End foreach Loop