Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

Returning file modified time as Blank -- why??

Highlighted
Puneet Bhatia_1
Occasional Contributor

Returning file modified time as Blank -- why??

Hi
I am trying to find the difference of system time and file last modified time(current_mtime -> calculated through stat command) for the searched files . But it is returning mtime as Blank(null value)for each searched files. Please help me, where i am making the mistake in this script


#!/usr/bin/perl
my $dir_path;
my $cmd;
my $buf;
use strict;
use File::Find;
use File::stat;
my $current_mtime;

$dir_path="/home";
$cmd="ll $dir_path > result";
`$cmd`;

open(MYINPUTFILE, "
while($buf=)
{
my @temp;
push @temp , split(/\s+/,$buf);
if ( $temp[8] =~ m/^mdc/i )
{
# Printing filename , Time and Date
print "\nFile $temp[8] last modified on $temp[7] $temp[6]\n";

find(\&syswanted, '$temp[8]');


# $now is current system unix time
my $now;
$now=`date '+%s'`;
print "\n Now : $now \n";
my $t;

#print "MTime: $current_mtime\n";
$t=($now-$current_mtime)/60;

print " Diff in minutes is: $t \n\n";

}
}


sub syswanted
{

my $file = $_;
print "File: $file\n";

$current_mtime = (stat($file))[8];
print "MTime: $current_mtime\n";

}