I/O Error 32 prevention.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
utz
Newbie
Posts: 18
Joined: Sat Aug 11, 2007 8:33 pm

I/O Error 32 prevention.

Post by utz » Thu Dec 06, 2007 8:02 am

Hello everyone,

I'm sure this is a common problem; I apologize if this has been posted before, but I didn't find anything. The issue is that I have a script that waits for an upload to a local disk (uploaded by another machine online to the FTP server running on the scripted machine)... I want to read the contents of this file as soon as it's uploaded, and so I just do an IfFileExists on the expected file and when it fires, I wait a couple seconds and then read the file's contents. This works almost all the time. However, the scripted machine is on a dialup, and sometimes it gets very slow, which can cause a I/O Error 32. If the conditional fires and then the script waits a few more seconds for the file to finish downloading, there is no guarantee that the download will be completed when the read is attempted, and this causes the error by creating a sharing violation between MS and the FTP server running on the same machine.

My hope is that someone has thought of a way to check for the completeness of a file after it's downloaded, other than using another file with a checksum equal to the size of the file I want to read (or something like that, which I don't want to do because this process needs to be as fast as possible). Is there a way in MS to tell if a file is currently locked by another process? Or is there a way to catch a I/O Error 32 within the script so it can recover?

Thanks!

Utz

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Dec 06, 2007 9:00 am

You could try this:

Code: Select all

Label>WaitFileReady
ReadLn>file,1,res
Pos>##ERR##,res,1,p
If>p>0
  //Must have been an error reading file, so wait and try again
  Wait>2
  Goto>WaitFileReady
Endif

//ok, no error, so we're good to go ...

If you want you can check for the specific error. The help file for ReadLn says:

If an error occurred, result is set to ##ERR## followed by the error code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

utz
Newbie
Posts: 18
Joined: Sat Aug 11, 2007 8:33 pm

Post by utz » Fri Dec 07, 2007 2:25 am

Hi Marcus,

Thank you; this worked. I forgot about readln being able to do that.

Much appreciated!

Utz

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts