Problem in access time

Discussion in 'Perl Misc' started by sanjeeb, May 1, 2006.

  1. sanjeeb

    sanjeeb Guest

    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";
    }

    }

    }


    ####################
     
    sanjeeb, May 1, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. engsol
    Replies:
    2
    Views:
    981
    Dan Bishop
    Jan 26, 2004
  2. Replies:
    8
    Views:
    495
    Magnus Lycka
    Aug 5, 2005
  3. Peter Hansen
    Replies:
    0
    Views:
    727
    Peter Hansen
    Feb 22, 2006
  4. Peter Hansen
    Replies:
    0
    Views:
    621
    Peter Hansen
    Feb 22, 2006
  5. flamesrock
    Replies:
    8
    Views:
    517
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page