On Tue, Feb 8, 2011 at 6:48 AM, Peter Bailey <pbailey / bna.com> wrote:

>> The likely problem though is that some other process, or even that
>> running your script, still has one of the files or directories you're
>> trying to move open and in use.  ¨Βοννογυμπςιτσ αςφιςυσγαξξεςσσο
>> if you have one of those, you might try temporarily disabling it and see
>> if that eliminates your problem.  ¨Βςαςε γασεσ¬ ιτ ισ ξεγεσσαςτο
>> remove such offending software entirely.
>>
>> -Jeremy
>
> I don't have the right to disable the virus scanner on this server.
> That's controlled by IT guys. I'll look into the SysInternals thing.
> I've used their stuff before. Thanks.

The nutshell here is that something -- possibly the virus scanner or
possibly some other software -- is touching the file when your script
runs, altering the permissions such that your script can't do what
it's trying to do. The problem isn't something unique to or endemic to
Ruby -- it's just a fundamental permissions issue. The solution is
simple. You just need to handle the exception that is generated.

begin
  #
  # Your code here.
  #
  FileUtils.mv("a","b")
rescue Errno::EACCES
  #
  # Well, dang. No permissions. So, do something to deal with it.
  #
  # You could sleep and 'retry', though you probably want to implement a
  # counter if you do that so that you aren't stuck in a loop forever.
  #
  # You could just write the offending file to a log somewhere.
  #
end


Kirk Haines
Engine Yard