I ran into the same thing. What I had to do is run a system command for a dir to a txt file. Then open the txt file and look at the date. I also had to format localtime to a MSDOS readable date/time. For Instance I created a perl script to check Backup Exec log files based on date.
Code to Acquire the NT MS-DOS Readable Date
# Acquire the Local Time Array
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time
+);
# Convert less the "10" so they equal a two char date.
$Month = $mon + "1";
if ($month < "10"){
$Month = '0' . "$Month";
}
if ($mday < "10"){
$mday = '0' . "$mday";
}
# Get the last two digits of a year, the way DOS sees file names.
$RealYear = substr($year, 1);
# This created $TimeStampDate into a format found in a DIR command in
+DOS. Ex. 03/28/01.
$TimeStampDate = "$Month". "/". "$mday" . "/" . "$RealYear";
Sub to create the cmd file to run,a nd run it.
sub CreateCmdFile {
$FileName = 'D:\\Perl\\pl\\Check\\' . "$CurrentServerName" . '
+.cmd';
unlink($FileName);
open(servercmd, "> $FileName");
print servercmd '@echo off' . "\n";
$VeritasLocation = '"\\\\' . "$CurrentServerName" . '\\C$\\Pro
+gram Files\\Veritas\\Backup Exec\\NT\\Data\\*.txt"';
print servercmd 'dir ' . "$VeritasLocation" . ' > D:\\Perl\\pl
+\\Check\\' . "$CurrentServerName" . '.txt';
close(servercmd);
system("$FileName");
}
Finally to check the .txt file vs. the date.
sub FindMatchingDates {
$ServerDirectoryFile = 'D:\\Perl\\pl\\Check\\' . "$CurrentServ
+erName" . '.txt';
open(logfilelisting, "$ServerDirectoryFile") or die "Unable to
+ open file: $!";
@CheckForMatchingDate = <logfilelisting>;
close(logfilelisting);
foreach (@CheckForMatchingDate) {
$SubOfCheckForMatchingDate = substr($_, 0, 8);
if ($SubOfCheckForMatchingDate eq $TimeStampDate){
$AssignedCorrectLogFile = substr($_, 39);
chomp($AssignedCorrectLogFile);
push(@CorrectLogFiles, "$AssignedCorrectLogFil
+e");
$LogFileFound = "1";
}
}
}
So in this case it pushes the Matching File name to @CorrectLogFile which can be used later.
Sgt
|