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

Running on a Windoze machine. I'm running into a problem with the following:

The process cannot access the file because it is being used by another process
If I'm in a loop, I can delete/unlink all but the last one.
The code is pretty basic:

# Both names are fully qualified... $cmd_shell = "Move $script_name $processed_script_name"; $return_code = `$cmd_shell`; if ( !(-e $processed_script_name) ) { $msg_text = "Error: Move (Processed:Script) command did not work:\n +" . " $cmd_shell\n" . " Return Code:\n" . " $return_code\n"; print $msg_text; }

The Move Statement (both paths exist):

Move F:\Alstom\habdata90\almarc\Processing\Appleton\Script_Files\av_20 +041216_142000_20041216_142500_ems.pl F:\Alstom\habdata90\almarc\Proce +ssed\Appleton\Script_Files\av_20041216_142000_20041216_142500_ems.pl

Any and all help would be appreciated by this Perl newbie...

2004-12-16 Janitored by Arunbear - added code tags around move statement, as per Monastery guidelines

Replies are listed 'Best First'.
Re: Process cannot Access file
by demerphq (Chancellor) on Dec 16, 2004 at 22:43 UTC

    On your "Windoze" machine open files normally can't be deleted or moved. Something you are doing in the loop that you havent posted is keeping a filehandle open prior to the move. Possibly/probably because you are using a global filehandle that isnt being closed as you exit scope. (This is no biggie, even someone like Schwern has fallen prey to this.)

    ---
    demerphq

Re: Process cannot Access file
by Stevie-O (Friar) on Dec 16, 2004 at 21:58 UTC
    I'm missing something here.
    • You have a Perl script to "perform an FTP". Are you downloading something via FTP, or are you uploading?
    • You 'execute it'. Does 'it' refer to the perl script?
    • You try to delete 'it'. Does 'it' refer to the perl script?
    Your sample code has nothing that refers to FTPing.

    It also does not delete any files; it does, however, try to move something.

    What exactly are you trying to accomplish here?

    I will not be able to help you until you answer at least some of these questions.

    --Stevie-O
    $"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc