debugger has asked for the wisdom of the Perl Monks concerning the following question:

I have to run my compiler on around 12000 files which are unit testcases. For this, i have a perl script "a.pl" which internally call another perl script "b.pl". "b.pl" invokes compiler_exe on the specified file. "a.pl" reads a file named files.txt containing list of file names on which the exe is to be invoked. Filenames are read from the files.txt one by one and its name is passed to "b.pl". "b.pl" invokes an exe on the file. The files.txt contain around 12000 file names. I need to two scripts because b.pl is like a wrapper for my compiler_exe which does some other things like setting options for the compiler to run with. However the problem is that, i get errors like "Access is denied" or "process cannot access the file as its being used by another process" on only FEW files(around 50 files).These 50 files are not the same always. The 12000 files are c files and they are not accessed by any other program or process. Perl : Active perl 5.8.8 for windows. On linux: There is no issue, everything works properly.

Replies are listed 'Best First'.
Re: Access is denied
by GrandFather (Saint) on Jan 04, 2010 at 06:15 UTC

    Most likely other processes are accessing files at the same time as your script. Most likely you can wait a little while then retry. If access is still denied then it may be that there is another process holding the file opened and thus locked.


    True laziness is hard work
Re: Access is denied
by cdarke (Prior) on Jan 04, 2010 at 12:33 UTC
    One possibility (on Windows) is that a virus checker or an indexer may be leaping in and using the files. Are these 50 files always different, or the same ones each time you run?

    Since these are C files: there are some occasions where Visual Studio retains locks if (when?) it crashes. Generally opening the file with VS then closing it again (without crashing) should clear it.
      Yes these 50 files are different always.Sometimes, i get a message on screen saying "virtual memory is low and so windows is trying to increase it and during such process access to some applications is denied". My machine's RAM size is 2GB and virtual memory is MIN:192MB and MAX:384MB. I run a compiler exe on those 12000 unit testcases.
Re: Access is denied
by ahmad (Hermit) on Jan 04, 2010 at 06:19 UTC

    I merely understand what you wrote, but I think what you've done is a total mess

    why would you need to use 2 scripts in the first place?

    What does the 'exe' program do

    what you're trying to accomplish by reading 12,000 files ??

    You are getting access denied error because you are trying to write data while the file is locked by another process as the error message explains

    if you can explain your problem using a well formatted node/replay ... We'll be able to assist you better.

      I have to run my compiler on around 12000 files which are unit testcases. For this, i have a perl script "a.pl" which internally call another perl script "b.pl". "b.pl" invokes compiler_exe on the specified file. "a.pl" reads a file named files.txt containing list of file names on which the exe is to be invoked. Filenames are read from the files.txt one by one and its name is passed to "b.pl". "b.pl" invokes an exe on the file. The files.txt contain around 12000 file names. I need to two scripts because b.pl is like a wrapper for my compiler_exe which does some other things like setting options for the compiler to run with. However the problem is that, i get errors like "Access is denied" or "process cannot access the file as its being used by another process" on only FEW files(around 50 files).These 50 files are not the same always. The 12000 files are c files and they are not accessed by any other program or process. Perl : Active perl 5.8.8 for windows. On linux: There is no issue, everything works properly.
Re: Access is denied
by matze77 (Friar) on Jan 04, 2010 at 13:49 UTC
    Maybe you want to use "lsof" on linux to find out what is blocking your file.
    On Windows you maybe want to use a sysinternals (now Microsoft) tool to see which files are open by which process,
    I leave it to you to find the appropriate tool ...
    It couldnt be that your scripts locks the open files cause there is an error?
    Your node was hard to read. Perhaps you could give a "formatted" sample code where people could see how you accomplish the opening e.g.