S
sanjeeb
Hey
I have written a code to know the files read by a tool during
execution so that i can anlyze that files only. The problem is that it
is not showing any file that was read. i checked manually(by renaming
the files and executing the tool, if it gives error means its read the
file) to know the files read during the execution of the tool(rom
tool).
Logic
1. Record the time at the start of the script.
2. Record the time at the end of the tool execution(rom).
3. Check the access time in the specified directory of each file using
stat.
4. If the access time is greater then the $time_start and less then the
$time_end
print the file name.
OS: WinXp, Active perl
Drive used: Virtual.
The tool is calling a batch file and the batch file in turn calls some
perl tool. The perl tool opens some file inside the script which are
present in the specified directory, but unfortunately it didnt show
that files.
1. Is there portability issue in the stat?
2. Is there any unkown bug in the code?
3. If a scipt open a file using "open", will it update the access time?
4. Is there any problem in the resolution, i think access time gives in
seconds(thats why i added a sleep after the "system" command).
Snippet of the code
###########################
use strict;
my $time_start = time;
system("rom -v coral -inst armv5 -build urel -s");
sleep(2);
my $time_end = time;
print "Time taken ($time_start - $time_end)\n";
use File::Find;
my @directories_to_search =
('C:\\J_Laptop\\J_Symbian\\eshell-min\\src\\cedar\\generic\\base\\e32\\rombuild');
print "\n";
find(\&wanted, @directories_to_search);
sub wanted {
if (-f $File::Find::name) {
my $st = stat($File::Find::name);
my $accessTime = $st->atime;
if ($accessTime >= $time_start && $accessTime <= $time_end) {
print "Files accessed #### $File::Find::name \n";
}
}
}
####################
With regards
Sanjeeb
I have written a code to know the files read by a tool during
execution so that i can anlyze that files only. The problem is that it
is not showing any file that was read. i checked manually(by renaming
the files and executing the tool, if it gives error means its read the
file) to know the files read during the execution of the tool(rom
tool).
Logic
1. Record the time at the start of the script.
2. Record the time at the end of the tool execution(rom).
3. Check the access time in the specified directory of each file using
stat.
4. If the access time is greater then the $time_start and less then the
$time_end
print the file name.
OS: WinXp, Active perl
Drive used: Virtual.
The tool is calling a batch file and the batch file in turn calls some
perl tool. The perl tool opens some file inside the script which are
present in the specified directory, but unfortunately it didnt show
that files.
1. Is there portability issue in the stat?
2. Is there any unkown bug in the code?
3. If a scipt open a file using "open", will it update the access time?
4. Is there any problem in the resolution, i think access time gives in
seconds(thats why i added a sleep after the "system" command).
Snippet of the code
###########################
use strict;
my $time_start = time;
system("rom -v coral -inst armv5 -build urel -s");
sleep(2);
my $time_end = time;
print "Time taken ($time_start - $time_end)\n";
use File::Find;
my @directories_to_search =
('C:\\J_Laptop\\J_Symbian\\eshell-min\\src\\cedar\\generic\\base\\e32\\rombuild');
print "\n";
find(\&wanted, @directories_to_search);
sub wanted {
if (-f $File::Find::name) {
my $st = stat($File::Find::name);
my $accessTime = $st->atime;
if ($accessTime >= $time_start && $accessTime <= $time_end) {
print "Files accessed #### $File::Find::name \n";
}
}
}
####################
With regards
Sanjeeb