You can also try to strace your script. In the logs you'll find the system
call causing the Permission denied...

On Tue, Feb 08, 2011 at 10:32:06PM +0900, Anurag Priyam wrote:
> > I've got Ruby scripts that have been working fine for years now. But,
> > every now and then, one of my scripts errors out with a "permission
> > denied" error. This is very frustrating. Usually, it involves moving a
> > file to either a sister directory or a subdirectory. And, like I said,
> > 99% of the time it works fine. Has anyone else experienced this? It kind
> > of scares me because it's only been happening for me with Ruby. It
> > didn't use to happen with Perl, and, believe, I don't want to go back to
> > Perl.
> 
> Can you post your code? Not sure, but trying to move '.' or '..' on a
> Unix system might cause this problem. Also, did you verify that you
> have right permissions on the files, and directories?
> 
> -- 
> Anurag Priyam
> http://about.me/yeban/
>