I am having a problem with a script that copies files to connected server drives. Since the problem is intermittent, I am left wondering if there is a timing issue involved. Can I expect each command in a script to complete before the next one is executed? My problem is that the error “disk no longer avaliable” frequently occurs when I do the copying.
For example, if I do several copy commands, in a repeat, (with replacing) and follow the ‘end repeat’ with an ‘eject’, is it possible for the ‘eject’ to occur before the copies are actually complete? If so, how can I make the script syncronous instead of asyncronous? If not, what else could explain this behavior? TIA.
If you use the Finder to “duplicate” files, it should wait before the copy is complete, unless you tell it explicitly to go ahead and ignore command’s results:
ignoring application responses
tell app "Finder" to duplicate x to y
end ignoring
--> eject
In this code, “eject” will be executed immediatelly after the “duplicate” command was sent, and most probably the duplication won’t be finished.
Stated this… I don’t know what could be your problem… Most probably anything network-related. Eg, some servers use a time limit for users. If the backup was not done in 30 minutes (for example), your connection will timeout and you will be disconnected from the server.
I think I found the problem. While the file actions may be synchronous, the ‘eject’ appears to be async. The next mount was occasionally occuring before the eject finished. I think that confused Finder and caused the problem. I have to let it run for a few cycles to see if the message comes back but so far it seems OK. I put a delay after the ‘eject’ command.