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
I/O Error 32 prevention.
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You could try this:
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.
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 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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?