From: Peter Bailey Date: 2009-02-21T04:24:29+09:00 Subject: Re: "permission denied" Igor Pirnovar wrote: > Peter Bailey wrote: >> Hi, >> I'm frustrated with one of my Ruby scripts. It's an image processing >> script that converts [sometimes thousands] of images and then HTTPs on >> to archival servers. I continue to get a "permission denied" error on >> one out of many files. > > Why not implementing something like the following to salvage your > processing, document (LOG) the problem and deal with it latter: > > ... > success = ProdOrca.sendPNG pngfile > if success == true then > ftpfile = File.new(filesuccess, "w") > ftp.putbinaryfile(filesuccess) > ftpfile.close > File.open("E:/logs/StatusReports/InfoConFiles.log", ... > else > ftpfile = File.new(fileerror, "w") > ftp.putbinaryfile(fileerror) > ftpfile.close > File.open("E:/logs/StatusReports/InfoConFiles.log", ... > end > ####### Salvage your operation and log the problematic files ###### > begin > FileUtils.rm(pngfile) <----- This is what it's complaining about. > rescue > puts "LOG: #{File.expand_path(file)} can not be handled" > end > ... Guess what? That's exactly what I did. Thanks a lot for your suggestion. Begin/Rescue comes through for me again. I realized that FileUtils would be full of "raises" and "exceptions," so, a begin/rescue should work just fine. I'm running the script now on about 1,400 files. -- Posted via http://www.ruby-forum.com/.